Re: Verilog Indentation

2007-02-04 Thread Albie Janse van Rensburg

Naim Far wrote:



Hi Vimers,

  Can anyone please help me with making the vim indent verilog files 
properly?!


Thanx in advance!





You will have to explain a bit more, if the following does not help. 

The wikipedia article (http://en.wikipedia.org/wiki/Verilog) claims 
Verilog has c-like syntax, so try out


:set cindent

or, if that doesn't work well, one or a combination of the following

:set smartindent
:set autoindent

Have a look in the vim help on the above, as well as

:help indentexpr

HTH


--
Albie Janse van Rensburg (neonpill)

Registered Linux User 438873 | 


Re: open multiple files with wildcard from inside vim

2007-02-04 Thread Cameron Simpson
On 05Feb2007 01:09, ben lieb <[EMAIL PROTECTED]> wrote:
| I thought I read once that I could open multiple files with a wildcard
| from within VIM (not from the command line).
| 
| I tried this:
| 
| :sp path/file*
| 
| And vim gives me "too many file names", even though there are only two
| files that match.

Have you tried:

  :n path/file*

That opens the first one and queues the others.

  :n

takes you to the next one and :p to the previous in the list.
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/


open multiple files with wildcard from inside vim

2007-02-04 Thread ben lieb
I thought I read once that I could open multiple files with a wildcard
from within VIM (not from the command line).

I tried this:

:sp path/file*

And vim gives me "too many file names", even though there are only two
files that match.

Any help appreciated.


[OT]Bram fortune file. Know your smileys.

2007-02-04 Thread Kazuo Teramoto

Hi,
I love the Bram fortune file (I read it all, is fun) but now looks it
be updated (with From "know your smileys" and jokes about proofs...)
but it is not updated in Bram site, anyone know from are Bram take the
'know your smileys'?

Bye.

PS. I love the vim list, really, I read it for fun, I don't post so
much but I think we have one of the best ml or better one of the best
user community.

--
«Dans la vie, rien n'est à craindre, tout est à comprendre»
Marie Sklodowska Curie.


Re: How to maximize my vim window when I start it?

2007-02-04 Thread A.J.Mechelynck

[EMAIL PROTECTED] wrote:

Hi,

The :set lines=9 columns=9 does not really maxmize the Vim window.
Since there's still borders for the window, a maximized window have no
borders (AFAIK this is true for WinXP and KDE).

Since you are highly unlikely to use a Windows version other than English
and Chinese. The following method works:

if has("gui_win32")   " NT Windows
autocmd GUIEnter * :simalt ~x
endif

Tony think the method is non-portable, that is true, if there's a portable
way to do the job, I will prefer the portable way. However, the :set
lines=9 columns=9 cannot do the same job as the :simalt can do, so
their must be a compromize. I would recommend the ":simalt" way until there
is a nature way for vim to cope with that.



":set lines=9 columns=9" expands the Vim screen to within 
approximately one character cell of the maximum. The full-screen size is 
usually not a multiple of the character cell so whatever method you use (even 
":simalt" there has to be an unused "fraction" of a cell's height and width 
around the borders. With my usual settings in kde (1024x768 display with 
two-row taskbar at bottom, gvim with GTK2 GUI, menu, toolbar and text-style 
tab bar displayed, 'guifont' set to "SUSE Sans Mono 9"), there may be a one- 
or two-pixel empty space around my Vim screen but I don't notice it; the most 
noticeable thing is that the "maximize/unmaximize" button shows a single 
rectangle rather than two overlapping ones.


Actually I tried clicking that button and the result is surprising: clicking 
it repeatedly cycles between _three_ states: maximized with the button showing 
one rectangle, maximized (same size) with button showing two overlapping 
rectangles, and not maximized (about 50% width and 75% height).


":simalt ~x" relies on Alt-Space x being the menu shortcut key to maximize. In 
a French version of Windows (as the one I used to have) it would be ":simalt 
~g" instead because the French version of Windows uses the g of Agrandir 
(rather than the x of Maximize) as the shortcut. Similarly for other languages 
and OSes. (The help for ":simalt" says {only for Win32 versions}; however I'm 
not on Windows and exists(":simalt") returns 2. Apparently that help page is 
outdated.)



Best regards,
Tony.


Re: How to maximize my vim window when I start it?

2007-02-04 Thread panshizhu
Hi,

The :set lines=9 columns=9 does not really maxmize the Vim window.
Since there's still borders for the window, a maximized window have no
borders (AFAIK this is true for WinXP and KDE).

Since you are highly unlikely to use a Windows version other than English
and Chinese. The following method works:

if has("gui_win32")   " NT Windows
autocmd GUIEnter * :simalt ~x
endif

Tony think the method is non-portable, that is true, if there's a portable
way to do the job, I will prefer the portable way. However, the :set
lines=9 columns=9 cannot do the same job as the :simalt can do, so
their must be a compromize. I would recommend the ":simalt" way until there
is a nature way for vim to cope with that.

--
Sincerely, Pan, Shi Zhu. ext: 2606


[EMAIL PROTECTED] wrote on 2007-02-05 07:26:38:

> Hi, everyone:
> I am now using gvim7.0 on WIN XP; I have several questions:
>
> 1. How to setup my gvim to open to the maximal size when I start it?
>



Re: Mapping with Shift, Ctrl and Alt/Meta

2007-02-04 Thread Bill McCarthy
On Sun 4-Feb-07 3:39pm -0600, A.J.Mechelynck wrote:

> I can't test Ctrl-Tab here because it's one of those keys
> which are preempted by the window manager (Ctrl-Tab and
> Ctrl-Shift-Tab cycle through virtual desktops the way
> Alt-Tab and Alt-Shift-Tab cycle through the open windows
> of the current desktop). Doesn't Vim see it as synonymous
> with Tab?
>
> Shift-Tab is a "meaningful" key (tab backwards) which is handled like
> non-printable keys (multibyte keyboard sequence dependent on the terminal).
> Vim can map such combos provided that it can see them.

Yes, in the Ctrl-V context, Ctrl-Tab behaves like Tab.
Ctrl-Shift-Tab, after Ctrl-V produces .

Otherwise, Ctrl-Tab works fine.  I use it regularly without
thinking about it.  From my _vimrc:

nmap   w
nmap   W

> I don't know how TheBat! gets its special-key keyboard
> input (raw or cooked for instance). IIUC, Vim uses
> "cooked" keyboard input, which is more portable across
> platforms and keyboard layouts, but is less powerful for
> complex key combinations since there is an additional
> software layer between the keyboard hardware and the
> program -- and that can conceivably lead to loss of
> information if the user presses a key combo not foreseen
> (or discarded as "not meaningful") by the translation
> software. Rather than a "bug", I would call it a
> "limitation" of the way Vim gets its keyboard input.

I agree that its more of a limitation than a bug.  It's too
bad - I start Gvim with go=M so I see no GUI stuff and work
with just the keyboard.  I find it easier to press a
modified keystroke (like Alt-Ctrl-k or Ctrl-Shift-k) then
multiple keystrokes (like k).  Plus it gives us far
more single keystroke commands (eight per key).

-- 
Best regards,
Bill



Re: How to maximize my vim window when I start it?

2007-02-04 Thread A.J.Mechelynck

Jiang Ting wrote:

Hi, everyone:

Thanks for the welcome. ^_^
Last week I emailed vim@vim.org from Outlook, but the server returned
all my email. Yesterday I tried to send email from my gmail account
directly, now it works.

I am now using gvim7.0 on WIN XP; I have several questions:

1. How to setup my gvim to open to the maximal size when I start it?


add to your vimrc the following 3 lines:

if has("gui_running")
set lines=9 columns=9
endif

Or, if you have a gvimrc, you can add

set lines=9 columns=9

to it. gvim will never use an actual size larger than what fits onscreen, so 
using a huge value effectively maximizes the screen. (In some cases there may 
be a one-character-cell rounding error.)


Another possibility would be to trigger the Alt-space menu (see ":help 
:simalt") but the command to use varies according to your locale and possibly 
your OS, so I don't recommend it.




2. I am using latex-suite; I want to setup macros like:
(1). `o=\theta;
(2). call IMAP('kk','\[<++>\]<++>','tex');

for (2), now I have to setup them every time when I use latex-suite;
how can I make them as default?


don't know



3. I am also writting Fortran 90 codes this semester and I want to
write like hw1.f90 and hw1.txt simultaneously; hw1.f90 for running,
hw1.txt for me to submit a hard copy to my Prof. How can I write the
same content in two files at the same time?


There are several possibilities:
- submit a hard copy on paper by using the ":hardcopy" command (q.v.) with the 
.f90 file

- copy the file with e.g. ":w %:r.txt" (without the quotes).
- set up an autocommand to do the above automatically, e.g.:

:au BufWritePost *.f90 w %:r.txt

(untested)


4. If I use:   :r !command, vim will include all the results given by
the shell command after where the index stay; Can I use:  :r command
to include the vim command?


not sure if I understand what you're asking for.
To capture the output of one or more Vim command(s), see ":help :redir".



5. :n,mw !command will take from the nth line to mth line as the shell 
command.

Can I use:  :n,mw command to do the same thing for vim command?


not sure if I understand.
- Every ex-command which can use a range (as shown in the help for that 
command) will accept (for instance) 5,10 between the : and the command name to 
act on lines 5 to 10. For instance :.,$s/\_s\+/\r/g will apply the substitute 
on all lines from the current line (.) to the end of the file ($), in this 
case breaking lines at any whitespace.

- Typing just :1234 (then Enter) will move the cursor to line 1234.
See ":help [range]" for details.



Hopfully I made all my questions clear. Thanks a lot.

Ting




Best regards,
Tony.


How to maximize my vim window when I start it?

2007-02-04 Thread Jiang Ting

Hi, everyone:

Thanks for the welcome. ^_^
Last week I emailed vim@vim.org from Outlook, but the server returned
all my email. Yesterday I tried to send email from my gmail account
directly, now it works.

I am now using gvim7.0 on WIN XP; I have several questions:

1. How to setup my gvim to open to the maximal size when I start it?

2. I am using latex-suite; I want to setup macros like:
(1). `o=\theta;
(2). call IMAP('kk','\[<++>\]<++>','tex');

for (2), now I have to setup them every time when I use latex-suite;
how can I make them as default?

3. I am also writting Fortran 90 codes this semester and I want to
write like hw1.f90 and hw1.txt simultaneously; hw1.f90 for running,
hw1.txt for me to submit a hard copy to my Prof. How can I write the
same content in two files at the same time?

4. If I use:   :r !command, vim will include all the results given by
the shell command after where the index stay; Can I use:  :r command
to include the vim command?

5. :n,mw !command will take from the nth line to mth line as the shell command.
Can I use:  :n,mw command to do the same thing for vim command?

Hopfully I made all my questions clear. Thanks a lot.

Ting


Re: Question on highlighting

2007-02-04 Thread DervishD
Hi Sean :)

 * Sean Hubbell <[EMAIL PROTECTED]> dixit:
>  I would like to be able to shade (use the same background color, but 
> make it lighter) the text between two braces (spanning multiple lines 
> and possibly nested). What is the best way to accomplish this?

If you're already using a syntax file (e.g. the vim runtime provides
a syntax file for the language you're interested in), you may dare to
modify it, or to write your own modifications in some "~/.vim/after/.*"
syntax file.

If exists a syntax file suitable for you in the vim runtime *and* it
already provides some "syntax group" for the text between two braces,
then you're lucky, because you just need to add something like:

hi Shaded ...
hi link NameOfTheGroup Shaded

To know what to put in the "...", see ":help highlight".

If you need to add your own group (or if no syntax file exists for
that language), I think that your best bet is using a region:

syntax region TextInBrackets start="{" end="}"
hi TextInBrackets ...

Again, see ":help highlight" and ":help syntax". If you could
ellaborate a bit on your problem (language you're using, which terminal
do you use, for example), I may give you more precise help regarding
colors, and the like.

I hope that helps :

Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!


Re: CTRL-S functionality to a letter combo like i.e. cs

2007-02-04 Thread DervishD
Hi Eric :)

 * Eric Leenman <[EMAIL PROTECTED]> dixit:
> When using vim on Linux these don't work anymore because of linux "windows 
> managers".

Well, that's not exact: the window manager may have its key mappings
for internal use, but it's X which is managing the keyboard. If the
window manager is using Ctrl-S, for example, you won't be able to use it
in your gvim, unfortunately. Well behaved window managers should allow
you to change the mappings (the Gnome window manager *is* well behaved,
for example).

> Is it possible to put the same functionality of the CTRL-key (and/or ALT) 
> to a key which is not linux "windows manager " sensitive?

Of course, use the mapping commands. See below for an example.

> In other words: Is it possible to remap the ctrl key to for example the 
> letter c?

Not a good idea in insert mode ;) but you can do it. For example,
even in insert mode, I've mapped "çç" to "gqip", but I'm still able to
type a "ç" or even a double "ç". Vim allows that :)

> So that when you are in insert-mode you can press cs as a replacement for 
> CTRL-S?

Let's say you don't use so much "cs", so you can afford to wait a
bit between "c" and "s" when you *actually* have to type that in insert
mode. Then, you can do this (for saving):

imap cs :w

But I suggest you to use the "Vim" keys for the task unless you're
very used to the C-S, C-X, C-V and C-C, because the vim keys work
everywhere and because things like "C-S" and "C-C" usually have other
meanings under Linux (namely, stop the character flow to the terminal,
and the keyboard interrupt, respectively). Vim keys and the vim way of
doing things is easy to learn. Believe it or not, after using vim for
only a month in my entire life, I'm so used to it that most of the time
I hit ":q" to exit from "elinks" or "Mutt"!

Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!


Re: Mapping with Shift, Ctrl and Alt/Meta

2007-02-04 Thread A.J.Mechelynck

Bill McCarthy wrote:

On Sun 4-Feb-07 11:57am -0600, A.J.Mechelynck wrote:


   

Alt+printable key is usually translated by (key OR 0x80).
Also Alt+ control keys above. This explains your
"decorated characters": for instance, since z is 0x7A,
Alt-z is mapped as 0xFA which (in Latin1 encoding) is ú
(small u with acute accent). Similarly, Alt-space should
map to 0xA0, the non-breaking space character known to
HTML writers as   This also means that Alt+printable
key should not be used for Insert-mode mappings because
they collide with accented characters which one may want
to be able to input directly.


Thanks for all that info on non-printables.  It is now easy
to figure out the Alt-x combos.


My pleasure. :-)






Depending on the underlying OS and window manager, some key combinations can
be preempted by the window manager, and never reach Vim. For instance, on my
Linux system with kwm window manager, Alt-Fn triggers a system menu or action,
Ctrl-Alt-Fn selects a virtual console ({1..12} are defined and {1..7,10} are
actually used) and Ctrl-Fn selects a virtual desktop (the number of such
virtual desktops is user-defined; I have 20 so all 12 Ctrl-Fn keys are taken).
Thus I can use Fn and Shift-Fn in gvim but not Ctrl-Fn, Alt-Fn or Ctrl-Alt-Fn
because the latter three kinds never reach any program running in X11.


I'm sure glad I don't have X11 to deal with :-)


It's the kind of thing one has to take into account when writing a vimrc for a 
dual-boot system, or a public script which could be used on any (g)vim 
installation. X11 has other advantages over Windows: I've used them both and 
I'm not going back.




Using Ctrl-V, I can see that Gvim doesn't see Alt-Ctrl or
Alt-Ctrl-Shift for "normal" keys, just for function keys,
insert/delete, home/end, page-up/down an the arrow keys.

This is NOT a Windows issue.  My email program (The Bat!),
for example, lets me make use of all of those combinations.
I believe it is a bug in the Gvim keyboard handling.

The tab key is a bit of an oddity.  Of the eight
possibilities, Ctrl-Tab and Alt-Ctrl-Tab don't work,
although Ctrl-Shift-Tab and Alt-Ctrl-Shift-Tab do work.
[Windows always takes over Alt-Tab and Alt-Shift-Tab.]



I can't test Ctrl-Tab here because it's one of those keys which are preempted 
by the window manager (Ctrl-Tab and Ctrl-Shift-Tab cycle through virtual 
desktops the way Alt-Tab and Alt-Shift-Tab cycle through the open windows of 
the current desktop). Doesn't Vim see it as synonymous with Tab?


Shift-Tab is a "meaningful" key (tab backwards) which is handled like 
non-printable keys (multibyte keyboard sequence dependent on the terminal). 
Vim can map such combos provided that it can see them.


I don't know how TheBat! gets its special-key keyboard input (raw or cooked 
for instance). IIUC, Vim uses "cooked" keyboard input, which is more portable 
across platforms and keyboard layouts, but is less powerful for complex key 
combinations since there is an additional software layer between the keyboard 
hardware and the program -- and that can conceivably lead to loss of 
information if the user presses a key combo not foreseen (or discarded as "not 
meaningful") by the translation software. Rather than a "bug", I would call it 
a "limitation" of the way Vim gets its keyboard input.



Best regards,
Tony.


Re: Mapping with Shift, Ctrl and Alt/Meta

2007-02-04 Thread Bill McCarthy
On Sun 4-Feb-07 11:57am -0600, A.J.Mechelynck wrote:


   
> Alt+printable key is usually translated by (key OR 0x80).
> Also Alt+ control keys above. This explains your
> "decorated characters": for instance, since z is 0x7A,
> Alt-z is mapped as 0xFA which (in Latin1 encoding) is ú
> (small u with acute accent). Similarly, Alt-space should
> map to 0xA0, the non-breaking space character known to
> HTML writers as   This also means that Alt+printable
> key should not be used for Insert-mode mappings because
> they collide with accented characters which one may want
> to be able to input directly.

Thanks for all that info on non-printables.  It is now easy
to figure out the Alt-x combos.



> Depending on the underlying OS and window manager, some key combinations can
> be preempted by the window manager, and never reach Vim. For instance, on my
> Linux system with kwm window manager, Alt-Fn triggers a system menu or action,
> Ctrl-Alt-Fn selects a virtual console ({1..12} are defined and {1..7,10} are
> actually used) and Ctrl-Fn selects a virtual desktop (the number of such
> virtual desktops is user-defined; I have 20 so all 12 Ctrl-Fn keys are taken).
> Thus I can use Fn and Shift-Fn in gvim but not Ctrl-Fn, Alt-Fn or Ctrl-Alt-Fn
> because the latter three kinds never reach any program running in X11.

I'm sure glad I don't have X11 to deal with :-)

Using Ctrl-V, I can see that Gvim doesn't see Alt-Ctrl or
Alt-Ctrl-Shift for "normal" keys, just for function keys,
insert/delete, home/end, page-up/down an the arrow keys.

This is NOT a Windows issue.  My email program (The Bat!),
for example, lets me make use of all of those combinations.
I believe it is a bug in the Gvim keyboard handling.

The tab key is a bit of an oddity.  Of the eight
possibilities, Ctrl-Tab and Alt-Ctrl-Tab don't work,
although Ctrl-Shift-Tab and Alt-Ctrl-Shift-Tab do work.
[Windows always takes over Alt-Tab and Alt-Shift-Tab.]

-- 
Best regards,
Bill



Re: Vim 7 performance notes

2007-02-04 Thread George V. Reilly

Yakov Lerner wrote:

On 2/4/07, Yakov Lerner <[EMAIL PROTECTED]> wrote:

On 2/4/07, Alexei Alexandrov <[EMAIL PROTECTED]> wrote:
> >
> > Gnu malloc (glibc) is exceptionally fast, iirc. It is possible
> > to benchmark the malloc speed during  the ./configure  time.
> > And auto-select the initital size depending on the results.
> >
> > The procmail this similar technique in configure: It automatically
> > benchmarks  it's own builtin strstr() vs system's strstr() and 
selects

> > the one which is faster.
> >
>
> In this particular case the speed of malloc is not the only factor.
> Big fraction of time is spent in memset() while initializing the array
> with zeros.

That's why I thought that it's reasonable to benchmark malloc()
relative to the time it takes to memset() that same area. (When
benchmarking, you need to know what to compare it to). If you
compare time it takes to malloc N bytes to the time it takes
to memset() same N bytes, you can tell the speed of malloc
*relative* to the time of memset()ting same size. So you will
automatically know which one is realtively more expensive,
the memset() or the malloc().


And then maybe the optimal initial size will be size where
memset() time is equal to the malloc() time ? The break-even,
so to say, in which neither of two time dominates the other ?


memset() is an O(N) operation. Its running time has to be proportional 
to N because it has to touch every single byte. If the pagefile gets 
involved, it's still O(N), but with a much larger constant.


malloc()'s running time is much harder to say anything about. Not only 
can it vary widely between different implementations, it also depends 
upon the state of the system. Is the heap fragmented? Is it suffering 
from lock contention? (Not a problem with single-threaded apps like 
Vim.) Is the memory already in the process's working set, or does malloc 
have to ask the OS for more pages? Is the system under intense memory 
pressure and will the malloc() operation cause paging to disk? Finally, 
malloc(N) is probably independent of N. It has to find a free entry of 
size N in its data structures, which is very dependent on both the 
implementation and the preceding factors. Benchmarking malloc() in 
./configure is not likely to tell you very much about its performance in 
a workload you care about.


--
/George V. Reilly  [EMAIL PROTECTED]
http://www.georgevreilly.com/blog
The biggest mistake is not learning from all your other mistakes.



Re: Go to start of visual selection

2007-02-04 Thread Andy Wokula

Tim Chase schrieb:

How can I move the cursor the start of the visual selection?
With the "o" command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The "`<" motion
followed by "gv" sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt `>:exec 'norm '.visualmode().'`'
vnoremap gb `:exec 'norm '.visualmode().'`>'

which gives you a "Go to the Top" and "Go to the Bottom" mapping within 
visual mode.


It can be a little funky in blockwise visual-mode, if your '< and '> 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the "top" will go to the top-right, not the top-left.  
I haven't figured out a good way to do this without considerably more 
code in the mapping (save the column of '< and then "gvO" to go back to 
visual-mode but in the other corner and then compare the columns to see 
which you want, perhaps needing to switch back...it's ugly).


However, it should work fine in character-wise and line-wise visual modes.

HTH,

-tim


Works fine at least for character-wise visual mode, thanks! :-)
IMHO, this little basic feature should be included in Vim.

Regards,
Andy

--
EOF




___ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de


Re: Vim 7 performance notes

2007-02-04 Thread Yakov Lerner

On 2/4/07, Yakov Lerner <[EMAIL PROTECTED]> wrote:

On 2/4/07, Alexei Alexandrov <[EMAIL PROTECTED]> wrote:
> >
> > Gnu malloc (glibc) is exceptionally fast, iirc. It is possible
> > to benchmark the malloc speed during  the ./configure  time.
> > And auto-select the initital size depending on the results.
> >
> > The procmail this similar technique in configure: It automatically
> > benchmarks  it's own builtin strstr() vs system's strstr() and selects
> > the one which is faster.
> >
>
> In this particular case the speed of malloc is not the only factor.
> Big fraction of time is spent in memset() while initializing the array
> with zeros.

That's why I thought that it's reasonable to benchmark malloc()
relative to the time it takes to memset() that same area. (When
benchmarking, you need to know what to compare it to). If you
compare time it takes to malloc N bytes to the time it takes
to memset() same N bytes, you can tell the speed of malloc
*relative* to the time of memset()ting same size. So you will
automatically know which one is realtively more expensive,
the memset() or the malloc().


And then maybe the optimal initial size will be size where
memset() time is equal to the malloc() time ? The break-even,
so to say, in which neither of two time dominates the other ?

Yakov


Re: Vim 7 performance notes

2007-02-04 Thread Yakov Lerner

On 2/4/07, Alexei Alexandrov <[EMAIL PROTECTED]> wrote:

>
> Gnu malloc (glibc) is exceptionally fast, iirc. It is possible
> to benchmark the malloc speed during  the ./configure  time.
> And auto-select the initital size depending on the results.
>
> The procmail this similar technique in configure: It automatically
> benchmarks  it's own builtin strstr() vs system's strstr() and selects
> the one which is faster.
>

In this particular case the speed of malloc is not the only factor.
Big fraction of time is spent in memset() while initializing the array
with zeros.


That's why I thought that it's reasonable to benchmark malloc()
relative to the time it takes to memset() that same area. (When
benchmarking, you need to know what to compare it to). If you
compare time it takes to malloc N bytes to the time it takes
to memset() same N bytes, you can tell the speed of malloc
*relative* to the time of memset()ting same size. So you will
automatically know which one is realtively more expensive,
the memset() or the malloc().

Yakov


Re: fileexist() funtion ?

2007-02-04 Thread Yakov Lerner

On 2/4/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:

Yakov Lerner wrote:
> I was searching for the reason why  initial-position-
> memory stopped working for me recently. It turned out the wrong
> ownership/perms of the ~/.viminfo file. ~/.viminfo existed,
> but was not readable and not writable by me.
> (vim does not warn, not in the slightest form).
>
> So I I want to insert the check for this special case into .vimrc.
> ( It happened once, it can happen again (maybe it happened to me more
> than once.
> I remember other mysterios cases when inititl-position stopped working
> and I did not know why)).
>
> So I need the fileexist() function in it's purest form. Because this
> check is not good:
>if filereadable(expand("~/.viminfo")) && !
> filewritable(expand("~/.viminfo")) |
>... warn...|endif
> This is not good. I need
>if fileexist(expand("~/.viminfo")) && !
> filewritable(expand("~/.viminfo")) | ... warn...|endif
> How can I check that file exists even though it is not readable ?
>
> Thanks
> Yakov
>

IIUC, Vim doesn't allow you to know of the existence of a file to which you
have neither read nor write permission


Just found how to do it:

if glob("~/.viminfo") != "" && ! filewritable(expand("~/.viminfo")) ...
Works nice. glob("~/.viminfo") returns non-empty string if file
exists, even if it is unreadable and unwritable.

Yakov


Re: fileexist() funtion ?

2007-02-04 Thread A.J.Mechelynck

Yakov Lerner wrote:

I was searching for the reason why  initial-position-
memory stopped working for me recently. It turned out the wrong
ownership/perms of the ~/.viminfo file. ~/.viminfo existed,
but was not readable and not writable by me.
(vim does not warn, not in the slightest form).

So I I want to insert the check for this special case into .vimrc.
( It happened once, it can happen again (maybe it happened to me more 
than once.

I remember other mysterios cases when inititl-position stopped working
and I did not know why)).

So I need the fileexist() function in it's purest form. Because this
check is not good:
   if filereadable(expand("~/.viminfo")) && !
filewritable(expand("~/.viminfo")) |
   ... warn...|endif
This is not good. I need
   if fileexist(expand("~/.viminfo")) && !
filewritable(expand("~/.viminfo")) | ... warn...|endif
How can I check that file exists even though it is not readable ?

Thanks
Yakov



IIUC, Vim doesn't allow you to know of the existence of a file to which you 
have neither read nor write permission, except by giving you an error ("access 
denied" or something) when you attempt to actually read or write it. I suppose 
this is a security feature: most files are readable to anybody and writable to 
their owner. Files readable by nobody (except the sysadmin and, if different, 
their owner) are usually "sensitive" files containing important information 
not to be made accessible to the common user.


To check for the existence of an unreadable file, you could (in Vim 7) try to 
read it, try to write it, and intercept the errors by means of 
try..catch..[finally..]endtry blocks:


- can't read, can write: file doesn't exist
- can't read, can't write: file is unreadable
- can read, can't write: file is readonly
- can read, can write: normal file


Best regards,
Tony.


Re: Mapping with Shift, Ctrl and Alt/Meta

2007-02-04 Thread A.J.Mechelynck

Bill McCarthy wrote:

Hello Vim List,

First I should mention that I'm using Windows and a native
compiler (MinGW).  Meta (M) and Alt (A) are exchangeable in
Windows - I use Alt (A) below.

For each function key, Vim should give me as many as 8 maps
per key.  All testing was done in normal mode.  To check
this, the following script was used:

map:echo "F7"
map  :echo "A-F7"
map  :echo "C-F7"
map  :echo "S-F7"
map:echo "A-C-F7"
map:echo "A-S-F7"
map:echo "C-S-F7"
map  :echo "A-C-S-F7"

The output of :map is:

   :echo "A-C-S-F7"
 :echo "C-S-F7"
 :echo "A-S-F7"
 :echo "A-C-F7"
   :echo "C-F7"
   :echo "A-F7"
   :echo "S-F7"
 :echo "F7"

All 8 work fine.  I tried this with special key 
and that also worked fine for all 8 variants.

Next I tried the letter z.  I used the same script as for
testing  but substituting f7 with z and replacing "map
" with "map z".  The output of :map is:

:echo "C-S-z"
Z:echo "S-z"
z:echo "z"
š:echo "A-C-S-z"
Ú:echo "A-S-z"
ú:echo "A-z"

Only 6 maps appear.  The  and  override each
other - they are not case sensitive.  No matter which way
they are defined, executing the map with either  or
 works fine.  I'm comfortable with this behavior.

The  and  also override each other.  However
the most recent define does not work.  It seems strange that
mapping the normal keyboard cannot be done with an Alt-Ctrl.

So although 6 maps appear in :map, only 5 actually work.

Finally, I tried comma.  The output of :map is:

,:echo ","
  :echo "A-C-S-,"
  :echo "C-S-,"
:echo "A-S-,"
:echo "A-C-,"
:echo "S-,"
:echo "C-,"
¬:echo "A-,"

All 8 appear, however only 2 work.  The working maps are for
"," and "A-,".  I expected  to map the '<' key.  I'm
surprised that  doesn't work - is it that way on 'nix
systems?

Should Vim store the 1 non-working map for z and the 6
non-working maps for comma?

Also, why doesn't  work for normal keyboard
characters?

Finally, why use these strange decorated characters for maps
containing an Alt?  These make the output of :map (and
relatives) useless for those mappings.



"Ctrl+printable key" is not portably defined for other than the following:
Ctrl-? 127 0x7F
Ctrl-@   0 0x00 NUL
Ctrl-A   1 0x01 also Ctrl-a
Ctrl-B   2 0x02 also Ctrl-b
Ctrl-C   3 0x03 also Ctrl-c
Ctrl-D   4 0x04 also Ctrl-d
Ctrl-E   5 0x05 also Ctrl-e
Ctrl-F   6 0x06 also Ctrl-f
Ctrl-G   7 0x07 BEL also Ctrl-g
Ctrl-H   8 0x08 BS  also Ctrl-h
Ctrl-I   9 0x09 HT  also Ctrl-i
Ctrl-J  10 0x0A LF  also Ctrl-j
Ctrl-K  11 0x0B also Ctrl-k
Ctrl-L  12 0x0C FF  also Ctrl-l
Ctrl-M  13 0x0D CR  also Ctrl-m
Ctrl-N  14 0x0E also Ctrl-n
Ctrl-O  15 0x0F also Ctrl-o
Ctrl-P  16 0x10 also Ctrl-p
Ctrl-Q  17 0x11 also Ctrl-q
Ctrl-R  18 0x12 also Ctrl-r
Ctrl-S  19 0x13 also Ctrl-s
Ctrl-T  20 0x14 also Ctrl-t
Ctrl-U  21 0x15 also Ctrl-u
Ctrl-V  22 0x16 also Ctrl-v
Ctrl-W  23 0x17 also Ctrl-w
Ctrl-X  24 0x18 also Ctrl-x
Ctrl-Y  25 0x19 also Ctrl-y
Ctrl-Z  26 0x1A also Ctrl-z
Ctrl-[  27 0x1B ESC
Ctrl-\  28 0x1C
Ctrl-]  29 0x1D
Ctrl-^  30 0x1E
Ctrl-_  31 0x1F

The above (which date back to the time of 8-bit computers, the first of which 
had only printable keys plus Shift and Ctrl; maybe even to the time of 7-bit 
teletypewriters) explain why Vim sees Tab and Ctrl-I, Enter and Ctrl-M, Esc 
and Ctrl-[ as pairs of synonyms.


Alt+printable key is usually translated by (key OR 0x80). Also Alt+ control 
keys above. This explains your "decorated characters": for instance, since z 
is 0x7A, Alt-z is mapped as 0xFA which (in Latin1 encoding) is ú (small u with 
acute accent). Similarly, Alt-space should map to 0xA0, the non-breaking space 
character known to HTML writers as   This also means that Alt+printable 
key should not be used for Insert-mode mappings because they collide with 
accented characters which one may want to be able to input directly.


Non-printable keys generate (with a few exceptions like Esc, Tab and Enter) 
more than one byte of keyboard data; and Alt and/or Ctrl and/or Shift 
combinations (with non-printable keys) are mapped separately. The translations 
 (which vary between terminal models) rely on the termcap/terminfo libraries 
(see ":help startup-terminal"). For instance, gvim uses "builtin_gui", a 
builtin entry (precompiled into gvim), and console Vim may use "linux", 
"xterm", "vt100" (which are common on Unix/Linux systems), "pcterm", "win32" 
(which are common on Dos/Windows systems) or something else depending on the 
particular console terminal it is using. The current terminal type is stored 
in the 'term' option (which cannot be changed in gvim). ":set termcap" 
displays the currently known terminal settings

fileexist() funtion ?

2007-02-04 Thread Yakov Lerner

I was searching for the reason why  initial-position-
memory stopped working for me recently. It turned out the wrong
ownership/perms of the ~/.viminfo file. ~/.viminfo existed,
but was not readable and not writable by me.
(vim does not warn, not in the slightest form).

So I I want to insert the check for this special case into .vimrc.
( It happened once, it can happen again (maybe it happened to me more than once.
I remember other mysterios cases when inititl-position stopped working
and I did not know why)).

So I need the fileexist() function in it's purest form. Because this
check is not good:
   if filereadable(expand("~/.viminfo")) && !
filewritable(expand("~/.viminfo")) |
   ... warn...|endif
This is not good. I need
   if fileexist(expand("~/.viminfo")) && !
filewritable(expand("~/.viminfo")) | ... warn...|endif
How can I check that file exists even though it is not readable ?

Thanks
Yakov


Re: color loading sequence in GVIM

2007-02-04 Thread A.J.Mechelynck

Eric Leenman wrote:

Hi,

I'm doing a reinstall of gvim and placing my color and font setting in a 
seperate file in the plugin.

This file is located in: "C:\Program Files\Vim\vimfiles\plugin"
And it contains the following:
[START OF FILE]
:hi Commentctermfg=darkgreen  gui=None guifg=darkgreen
:hi Statement  ctermfg=blue   gui=None guifg=blue
:hi Identifier ctermfg=darkredgui=None guifg=darkred
:hi PreProcctermfg=blue   gui=None guifg=darkblue
:hi Type   ctermfg=darkgray   gui=None guifg=darkgray
:hi Constant   ctermfg=redgui=None guifg=red

" GUI font instellingen
set guifont=courier:h7:w7
[END OF FILE]


What now happens is that the font is taken over but the colors aren't
For example:
When I type :hi Comment
vim returns:
Comment   xxx term=bold ctermfg=1 guifg=Blue

What do I do wrong?

Regards,
Eric


Maybe you are setting your colors too early. Try writing a colorscheme 
instead, then invoking it with the ":colorscheme" command (q.v.). I'm 
attaching my "almost-default" colorscheme as a relatively simple source of 
inspiration.


Colorscheme scripts live in the "colors" subdirectory of directories in 
'runtimepath', for instance in:

(user-private on Linux) ~/.vim/colors/
(user-private on Windows) ~/vimfiles/colors/
(system-wide on any platform) $VIM/vimfiles/colors/


Best regards,
Tony.
" Vim color file
" Maintainer:   Tony Mechelynck <[EMAIL PROTECTED]>
" Last Change:  2006 Sep 06
" 
" This is almost the default color scheme.  It doesn't define the Normal
" highlighting, it uses whatever the colors used to be.

" Only the few highlight groups named below are defined; the rest (most of
" them) are left at their compiled-in default settings.

" Set 'background' back to the default.  The value can't always be estimated
" and is then guessed.
hi clear Normal
set bg&

" Remove all existing highlighting and set the defaults.
hi clear

" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
  syntax reset
endif

" Set our own highlighting settings
hi SpecialKey   guibg=NONE
hi PyjamaEven   ctermbg=greygui=NONEguibg=#FFD8FF
" white on red is not always distinct in the GUI: use black on red then
hi Errorguibg=red   
guifg=black
hi clear ErrorMsg
hi link  ErrorMsg   Error
" show cursor line/column (if enabled) in very light grey in the GUI,
" underlined in the console
if has("gui_running")
  hi clear CursorLine
  hi CursorLine guibg=#F4F4F4
endif
hi clear CursorColumn
hi link  CursorColumn   CursorLine
" do not make help bars and stars invisible
hi clear helpBar
hi link  helpBarhelpHyperTextJump
hi clear helpStar
hi link  helpStar   helpHyperTextEntry
" the following were forgotten in the syntax/vim.vim (and ended up cleared)
hi clear vimVar
hi link  vimVar Identifier
hi clear vimGroupName
hi link  vimGroupName   vimGroup
hi clear vimHiClear
hi link  vimHiClear vimHighlight
" display the status line of the active window in a distinctive color:
" bold white on bright red in the GUI, white on green in the console (where the 
bg is
" never bright, and dark red is sometimes an ugly sort of reddish brown).
hi StatusLine   gui=NONE,bold   guibg=red   
guifg=white
\   cterm=NONE,bold ctermbg=green   
ctermfg=white
" make the status line bold-reverse (but B&W) for inactive windows
hi StatusLineNC gui=reverse,bold
\   cterm=reverse,bold
" define colors for the tab line:
" file name of unselected tab
hi TabLine  gui=NONEguibg=#EE   
guifg=black
\   cterm=NONE,bold ctermbg=lightgrey   
ctermfg=white
" file name of selected tab (GUI default is bold black on white)
hi TabLineSel   cterm=NONE,bold ctermbg=green   
ctermfg=white
" fillup and tab-delete "X" at right
hi TabLineFill  gui=NONE,bold   guibg=#CC   
guifg=#AA
\   cterm=NONE  ctermbg=lightgrey   
ctermfg=red
" tab and file number 1:2/3 (meaning "tab 1: window 2 of 3) for selected tab
hi User1gui=boldguibg=white 
guifg=magenta
\   ctermbg=green   
ctermfg=black
" tab and file number 1:2/3 for unselected tab
hi User2guibg=#EE   
guifg=magenta
\   ctermbg=lightgrey   
ctermfg=black
" additional override for manpages à la Dr. Chip
hi manSubSectionStart   guibg=white 
guifg=yellow
\   ctermbg=black   
ctermfg=darkblue

" remember the current colorscheme 

Mapping with Shift, Ctrl and Alt/Meta

2007-02-04 Thread Bill McCarthy
Hello Vim List,

First I should mention that I'm using Windows and a native
compiler (MinGW).  Meta (M) and Alt (A) are exchangeable in
Windows - I use Alt (A) below.

For each function key, Vim should give me as many as 8 maps
per key.  All testing was done in normal mode.  To check
this, the following script was used:

map:echo "F7"
map  :echo "A-F7"
map  :echo "C-F7"
map  :echo "S-F7"
map:echo "A-C-F7"
map:echo "A-S-F7"
map:echo "C-S-F7"
map  :echo "A-C-S-F7"

The output of :map is:

   :echo "A-C-S-F7"
 :echo "C-S-F7"
 :echo "A-S-F7"
 :echo "A-C-F7"
   :echo "C-F7"
   :echo "A-F7"
   :echo "S-F7"
 :echo "F7"

All 8 work fine.  I tried this with special key 
and that also worked fine for all 8 variants.

Next I tried the letter z.  I used the same script as for
testing  but substituting f7 with z and replacing "map
" with "map z".  The output of :map is:

:echo "C-S-z"
Z:echo "S-z"
z:echo "z"
š:echo "A-C-S-z"
Ú:echo "A-S-z"
ú:echo "A-z"

Only 6 maps appear.  The  and  override each
other - they are not case sensitive.  No matter which way
they are defined, executing the map with either  or
 works fine.  I'm comfortable with this behavior.

The  and  also override each other.  However
the most recent define does not work.  It seems strange that
mapping the normal keyboard cannot be done with an Alt-Ctrl.

So although 6 maps appear in :map, only 5 actually work.

Finally, I tried comma.  The output of :map is:

,:echo ","
  :echo "A-C-S-,"
  :echo "C-S-,"
:echo "A-S-,"
:echo "A-C-,"
:echo "S-,"
:echo "C-,"
¬:echo "A-,"

All 8 appear, however only 2 work.  The working maps are for
"," and "A-,".  I expected  to map the '<' key.  I'm
surprised that  doesn't work - is it that way on 'nix
systems?

Should Vim store the 1 non-working map for z and the 6
non-working maps for comma?

Also, why doesn't  work for normal keyboard
characters?

Finally, why use these strange decorated characters for maps
containing an Alt?  These make the output of :map (and
relatives) useless for those mappings.

-- 
Best regards,
Bill



color loading sequence in GVIM

2007-02-04 Thread Eric Leenman

Hi,

I'm doing a reinstall of gvim and placing my color and font setting in a 
seperate file in the plugin.

This file is located in: "C:\Program Files\Vim\vimfiles\plugin"
And it contains the following:
[START OF FILE]
:hi Commentctermfg=darkgreen  gui=None guifg=darkgreen
:hi Statement  ctermfg=blue   gui=None guifg=blue
:hi Identifier ctermfg=darkredgui=None guifg=darkred
:hi PreProcctermfg=blue   gui=None guifg=darkblue
:hi Type   ctermfg=darkgray   gui=None guifg=darkgray
:hi Constant   ctermfg=redgui=None guifg=red

" GUI font instellingen
set guifont=courier:h7:w7
[END OF FILE]


What now happens is that the font is taken over but the colors aren't
For example:
When I type :hi Comment
vim returns:
Comment   xxx term=bold ctermfg=1 guifg=Blue

What do I do wrong?

Regards,
Eric

_
Check out all that glitters with the MSN Entertainment Guide to the Academy 
Awards®   http://movies.msn.com/movies/oscars2007/?icid=ncoscartagline2




Verilog Indentation

2007-02-04 Thread Naim Far



Hi Vimers,

  Can anyone please help me with making the vim indent verilog files 
properly?!


Thanx in advance!





Re: Go to start of visual selection

2007-02-04 Thread Andy Wokula

Tim Chase schrieb:

How can I move the cursor the start of the visual selection?
With the "o" command, yes.  But how can I make sure the cursor
is at the start while visual mode is on?  The "`<" motion
followed by "gv" sets the cursor back to the end if it was
there.


I think it sounds like you want something like the following:

vnoremap gt `>:exec 'norm '.visualmode().'`'
vnoremap gb `:exec 'norm '.visualmode().'`>'

which gives you a "Go to the Top" and "Go to the Bottom" mapping within 
visual mode.


It can be a little funky in blockwise visual-mode, if your '< and '> 
points are top-right and bottom-left (rather than top-left and 
bottom-right), as the "top" will go to the top-right, not the top-left.  
I haven't figured out a good way to do this without considerably more 
code in the mapping (save the column of '< and then "gvO" to go back to 
visual-mode but in the other corner and then compare the columns to see 
which you want, perhaps needing to switch back...it's ugly).


However, it should work fine in character-wise and line-wise visual modes.

HTH,

-tim


I don't understand why this works.

There must be a difference between
`>v`<
and
:normal `>v`<

"v" defines a new visual area and overwrites the `<,`> markers.  Why
does "`<" after ":normal" move the cursor to the start of the
_previously_ selected visual area?

Thx,
Andy

--
kühl, @vim.org ist wieder zurück

EOF






___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de


Re: replace with a number sequence

2007-02-04 Thread Naim Far

Hi Vimers,

  Can anyone please help me with making the vim indent verilog files 
properly?!


Thanx in advance!