patch 7.0.190

2007-02-04 Thread Bram Moolenaar

Patch 7.0.190
Problem:syntax spell default results in an error message.
Solution:   Change 4 to 7 for STRNICMP(). (Raul Nunez de Arenas Coronado)
Files:  src/syntax.c


*** ../vim-7.0.189/src/syntax.c Wed Nov  1 12:43:07 2006
--- src/syntax.cSun Jan 21 13:12:19 2007
***
*** 3206,3212 
curbuf-b_syn_spell = SYNSPL_TOP;
  else if (STRNICMP(arg, notoplevel, 10) == 0  next - arg == 10)
curbuf-b_syn_spell = SYNSPL_NOTOP;
! else if (STRNICMP(arg, default, 4) == 0  next - arg == 4)
curbuf-b_syn_spell = SYNSPL_DEFAULT;
  else
EMSG2(_(E390: Illegal argument: %s), arg);
--- 3206,3212 
curbuf-b_syn_spell = SYNSPL_TOP;
  else if (STRNICMP(arg, notoplevel, 10) == 0  next - arg == 10)
curbuf-b_syn_spell = SYNSPL_NOTOP;
! else if (STRNICMP(arg, default, 7) == 0  next - arg == 7)
curbuf-b_syn_spell = SYNSPL_DEFAULT;
  else
EMSG2(_(E390: Illegal argument: %s), arg);
*** ../vim-7.0.189/src/version.cSun Feb  4 02:37:40 2007
--- src/version.c   Sun Feb  4 02:40:23 2007
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 190,
  /**/

-- 
From know your smileys:
 :-)-O  Smiling doctor with stethoscope

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


patch 7.0.191

2007-02-04 Thread Bram Moolenaar

Patch 7.0.191 
Problem:The items used by getqflist() and setqflist() don't match.
Solution:   Support the bufnum item for setqflist(). (Yegappan Lakshmanan)
Files:  runtime/doc/eval.txt, src/quickfix.c


*** ../vim-7.0.190/runtime/doc/eval.txt Wed Nov  1 15:31:02 2006
--- runtime/doc/eval.txtSun Feb  4 01:54:35 2007
***
*** 2897,2908 
vcolnon-zero: col is visual column
zero: col is byte index
nr  error number
textdescription of the error
typetype of the error, 'E', '1', etc.
valid   non-zero: recognized error message
  
When there is no error list or it's empty an empty list is
!   returned.
  
Useful application: Find pattern matches in multiple files and
do something with them: 
--- 2912,2925 
vcolnon-zero: col is visual column
zero: col is byte index
nr  error number
+   pattern search pattern used to locate the error
textdescription of the error
typetype of the error, 'E', '1', etc.
valid   non-zero: recognized error message
  
When there is no error list or it's empty an empty list is
!   returned. Quickfix list entries with non-existing buffer
!   number are returned with bufnr set to zero.
  
Useful application: Find pattern matches in multiple files and
do something with them: 
***
*** 4371,4377 
Non-dictionary items in {list} are ignored.  Each dictionary
item can contain the following entries:
  
!   filenamename of a file
lnumline number in the file
pattern search pattern used to locate the error
col column number
--- 4401,4410 
Non-dictionary items in {list} are ignored.  Each dictionary
item can contain the following entries:
  
!   bufnr   buffer number; must be the number of a valid
!   buffer
!   filenamename of a file; only used when bufnr is not
!   present or it is invalid.
lnumline number in the file
pattern search pattern used to locate the error
col column number
***
*** 4384,4394 
The col, vcol, nr, type and text entries are
optional.  Either lnum or pattern entry can be used to
locate a matching error line.
!   If the filename entry is not present or neither the lnum
!   or pattern entries are present, then the item will not be
!   handled as an error line.
If both pattern and lnum are present then pattern will
be used.
  
If {action} is set to 'a', then the items from {list} are
added to the existing quickfix list. If there is no existing
--- 4417,4429 
The col, vcol, nr, type and text entries are
optional.  Either lnum or pattern entry can be used to
locate a matching error line.
!   If the filename and bufnr entries are not present or
!   neither the lnum or pattern entries are present, then the
!   item will not be handled as an error line.
If both pattern and lnum are present then pattern will
be used.
+   Note that the list is not exactly the same as what
+   |getqflist()| returns.
  
If {action} is set to 'a', then the items from {list} are
added to the existing quickfix list. If there is no existing
*** ../vim-7.0.190/src/quickfix.c   Fri Oct 20 20:15:05 2006
--- src/quickfix.c  Sun Feb  4 01:50:17 2007
***
*** 106,112 
  
  static intqf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, 
typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T 
lnumlast));
  static void   qf_new_list __ARGS((qf_info_T *qi));
! static intqf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u 
*dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, char_u 
*pattern, int nr, int type, int valid));
  static void   qf_msg __ARGS((qf_info_T *qi));
  static void   qf_free __ARGS((qf_info_T *qi, int idx));
  static char_u *qf_types __ARGS((int, int));
--- 106,112 
  
  static intqf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, 
typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, 

Re: Vim 7 performance notes

2007-02-04 Thread Yakov Lerner

On 2/4/07, Bram Moolenaar [EMAIL PROTECTED] wrote:


Alexei Alexandrov wrote:

 I'm doing some performance investigations of Vim code trying to
 understand whether there are any possibilities to improve it.
 Currently I've made the following observations (all investigations are
 done on Windows):

 Redundant work is done during regexp operations in syntax
 highlighting. On some files it is very noticable. The stack of the
 hotspot is ...  syn_current_attr  syn_regexec  vim_regexec_multi 
 vim_regexec_both  regtry  regmatch  ga_grow  alloc_clear  memset.
 So alloc_clear spends quite a few clockticks in lalloc() and memset().
 The reason for this is pessimistically big grow size for regset
 growing array:

 ga_init2(regstack, 1, 1);

 This is not very good: many regexp operations don't go deep -
 non-match is detected very quickly. But even one element on the stack
 will lead to allocating at least 1 bytes (which should be fast
 with good CRT memory allocator) and (worse) initializing these 1
 bytes with zeros (won't be that fast).

 One possible solution would be to keep regstack alive across calls to
 vim_regexec_both, but I'm not sure if it's can be done safely. What I
 did was replacing the grow size with smaller number and making the
 grow size for growing arrays dynamic with increase of 25%:

 --- regexp.c (revision 136)
 +++ regexp.c (working copy)
 @@ -3350,7 +3350,7 @@
  /* Init the regstack empty.  Use an item size of 1 byte, since we push
   * different things onto it.  Use a large grow size to avoid reallocating
   * it too often. */
 -ga_init2(regstack, 1, 1);
 +ga_init2(regstack, 1, 64);

  /* Init the backpos table empty. */
  ga_init2(backpos, sizeof(backpos_T), 10);

 --- misc2.c (revision 136)
 +++ misc2.c (working copy)
 @@ -1905,6 +1905,7 @@

  {
   if (n  gap-ga_growsize)
   n = gap-ga_growsize;
 +gap-ga_growsize += (gap-ga_growsize  2);
   len = gap-ga_itemsize * (gap-ga_len + n);
   pp = alloc_clear((unsigned)len);
   if (pp == NULL)

 With this change I can see serious performance improvements, but I'm
 not sure if they are safe.
 Bram, does it look making any sense?

This is a tradeoff between allocating too much and allocating too often.
What works best completely depends on the implementation of malloc() and
free().  I know that there are many implementations where they are quite
slow.  Then allocating larger chunks less often is better.  On some
systems they are fast and the chunks can be smaller.


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.

Yakov


Compilation error with -D EXITFREE

2007-02-04 Thread Alexei Alexandrov
Hi All!

Do I understand it correct that EXITFREE define in Vim source code can be used 
to make sure all resources are cleaned up on exit (and those which are not 
should be treated as leaks)? To be able to use it on Windows I had to do the 
following changes:

Index: misc2.c
===
--- misc2.c (revision 205)
+++ misc2.c (working copy)
@@ -1075,7 +1075,7 @@
 ResetRedobuff();
 ResetRedobuff();
 
-#ifdef FEAT_CLIENTSERVER
+#if defined(FEAT_CLIENTSERVER)  defined(FEAT_X11)
 vim_free(serverDelayedStartName);
 #endif
 
Index: os_mswin.c
===
--- os_mswin.c (revision 205)
+++ os_mswin.c (working copy)
@@ -239,6 +239,11 @@
 
 if (gui.in_use)
  gui_exit(r);
+
+#ifdef EXITFREE
+free_all_mem();
+#endif
+
 exit(r);
 }

-- 
Alexei Alexandrov


Re: Vim 7 performance notes

2007-02-04 Thread Bram Moolenaar

Alexei Alexandrov wrote:

 
  The idea to gradually increase the chunk size makes sense, but not
  everywhere.  For the syntax stack it's probably better to start with a
  stack that is mostly needed, then growing quite quickly (say double the
  chunk size every time).  That's because when recursive things are
  involved we need much more space.  And copying the stack to another
  place is more expensive than clearing with zeroes.
 
  Perhaps you can do some investigation about what the size mostly ends up
  to be.  Then use that with a special version of ga_grow() that increases
  the chunk size every time.
 
 I've also tried the approach with persisting the regstack and backpos
 allocation across calls to vim_regexec_both. It seems to work even
 better than increasing the grow size in my particular test cases. And
 I can't think up any situation when it can slow things down. Could you
 please take a look at the patch attached and provide your opinion?

Speed should be OK this way, but it does keep up to 32 Kbyte allocated.
That may not seem much, but if we do this in many places it quickly adds
up.

Can you show the benchmarks you used to see the performance and the
stack space that is being used?  Otherwise we keep guessing the best
numbers.

Coding detail: please don't use if (!number), use if (number == 0),
that is so much easier to read.  Checking if ga_data is NULL would be
simpler.

-- 
From know your smileys:
 :q vi user saying, How do I get out of this damn emacs editor?

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Compilation error with -D EXITFREE

2007-02-04 Thread Bram Moolenaar

Alexei Alexandrov wrote:

 Do I understand it correct that EXITFREE define in Vim source code can
 be used to make sure all resources are cleaned up on exit (and those
 which are not should be treated as leaks)? To be able to use it on
 Windows I had to do the following changes:

Thanks for the patch.  I never tried EXITFREE on Win32.  What memory
checker to you use with it?  Aren't there Win32-specific things that
need to be freed?

-- 
From know your smileys:
 (:-#   Said something he shouldn't have

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Inconsistent return from exists()

2007-02-04 Thread A.J.Mechelynck

Bram Moolenaar wrote:

Tony Mechelynck wrote:


In

VIM - Vi IMproved 7.0 (2006 May 7, compiled Feb  4 2007 03:42:30)
Included patches: 1-191
Compiled by [EMAIL PROTECTED]
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
[...]

exists(:simalt) or exists(:tearoff) return 2; however trying to use them 
results in


E319: Sorry, the command is not available in this version


Shouldn't the call to exists() have returned 0 (zero)?


The command exists but it doesn't work.  That is more something for
has() to figure out.  But it doesn't handle Ex commands specifically,
you can only find out by check for certain features.

I can add this to the todo list, but don't expect it soon.



OK, well, I guess it's a case of better late than never or if you (Tony) 
want it real bad, then program it yourself ;-/



Best regards,
Tony.


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!



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 esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

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


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!





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




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 f7   :echo F7CR
map a-f7 :echo A-F7CR
map c-f7 :echo C-F7CR
map s-f7 :echo S-F7CR
map a-c-f7   :echo A-C-F7CR
map a-s-f7   :echo A-S-F7CR
map c-s-f7   :echo C-S-F7CR
map a-c-s-f7 :echo A-C-S-F7CR

The output of :map is:

M-C-S-F7   :echo A-C-S-F7CR
C-S-F7 :echo C-S-F7CR
M-S-F7 :echo A-S-F7CR
M-C-F7 :echo A-C-F7CR
C-F7   :echo C-F7CR
M-F7   :echo A-F7CR
S-F7   :echo S-F7CR
F7 :echo F7CR

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

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

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

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

The A-C-z and A-C-S-z 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 ,CR
C-S-¬  :echo A-C-S-,CR
C-S-,  :echo C-S-,CR
S-¬:echo A-S-,CR
C-¬:echo A-C-,CR
S-,:echo S-,CR
C-,:echo C-,CR
¬:echo A-,CR

All 8 appear, however only 2 work.  The working maps are for
, and A-,.  I expected S-, to map the '' key.  I'm
surprised that C-, 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 A-C-key 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



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: 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 f7   :echo F7CR
map a-f7 :echo A-F7CR
map c-f7 :echo C-F7CR
map s-f7 :echo S-F7CR
map a-c-f7   :echo A-C-F7CR
map a-s-f7   :echo A-S-F7CR
map c-s-f7   :echo C-S-F7CR
map a-c-s-f7 :echo A-C-S-F7CR

The output of :map is:

M-C-S-F7   :echo A-C-S-F7CR
C-S-F7 :echo C-S-F7CR
M-S-F7 :echo A-S-F7CR
M-C-F7 :echo A-C-F7CR
C-F7   :echo C-F7CR
M-F7   :echo A-F7CR
S-F7   :echo S-F7CR
F7 :echo F7CR

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

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

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

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

The A-C-z and A-C-S-z 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 ,CR
C-S-¬  :echo A-C-S-,CR
C-S-,  :echo C-S-,CR
S-¬:echo A-S-,CR
C-¬:echo A-C-,CR
S-,:echo S-,CR
C-,:echo C-,CR
¬:echo A-,CR

All 8 appear, however only 2 work.  The working maps are for
, and A-,.  I expected S-, to map the '' key.  I'm
surprised that C-, 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 A-C-key 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 nbsp; 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 

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: 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: 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: 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 esc`:exec 'norm '.visualmode().'`lt'cr
vnoremap gb esc`lt:exec 'norm '.visualmode().'`'cr

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 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: 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:

snip
   

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 nbsp; 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. :-)



snip


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: 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 C-O: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: 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!


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: 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.


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 C-S-Tab.

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

nmap silent C-Tab C-Ww
nmap silent S-Tab C-WW

 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 leaderk).  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 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?




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.


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/


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 | http://counter.li.org