Re: buffer list count

2006-11-14 Thread Milan Vancura
Hi,

 When my .vimrc is running, creating the BufAdd autocmds, all of the
 files (*.c) I think already have buffers assigned to them. I'm not sure,
 but this could cause the problem. A simple fix would just be a manual
 buffer count on VimEnter. I'm getting close to the best solution.

I think this would be great chance to to it realy fast:

1. define a function which counts all buffers and stores the count to a global
variable bufcount

2. start this function in .vimrc to initialize bufcount

3. add bufcount to your ruler

4. add BufEnter and BufLeave autocommands which increase/decrease bufcount var.


With this solution you just show a static variable in your ruler, it's as fast
as possible. And if you're in doubt, you can call the initialize function -
this will be your redraw analogy


I think this solution would be nice - if you can execute the .vimrc code after
all buffers loading. Which is not the default, I think. Mainly because the
BufEnter autocommand definitions set in .vimrc couldn't work for opening files
mentioned at cmdline... So there must be a trick to delay some .vimrc code
execution.

Milan Vancura


wrong direction of 'n' -- when #,n are remapped and inside function

2006-11-14 Thread Yakov Lerner

In the script below, where # and n are remapped,
n goes the wrong direction after #. To see:
   vim -u NONE bad.bim
   :so %
   gg/bacrnnn#n
-- the last n goes forward. we expect it to move backward.

But when script is rewritten to the form #2, then n after # works
correcty.  Plain moving the 'silent! exe norm!...' out of the
function changes the behavior.

Yakov
-- bad.vim 
 ba ba ba ba ba ba ba ba
:set nocp
nnoremap # :call Foo('#')cr
nnoremap n :call Foo('n')cr

func! Foo(cmd)
  silent! exe norm!  . a:cmd
endfun

 test sequence: gg/bacrnnn#n
 expected: last 'n' to go backwards
 actual  : last 'n' to go forward

Form 2 that works ok
- ok.vim ---
 ba ba ba ba ba ba ba ba
:set nocp
nnoremap # :silent! exe norm! #cr
nnoremap n :silent! exe norm! ncr

 test sequence: gg/bacrnnn#n
 expected: last 'n' to go backwards
 actual  : ok



Re: (patch), global var that indicates default search direction

2006-11-14 Thread Bram Moolenaar

Yakov Lerner wrote:

 In addition to @/, this adds global variable that indicates
 default search direction (1-forward, 0-backward).
 
 Doc patch is inluded.
 
 The variable name, v:patdir, is not perfect. But I could not think
 of better name. v:searchdir would be even worse (search directories ?)

Good idea to make this available.

I think the variable should be writable, so that when you set @/ you can
also set the search direction.

For the name: How about v:searchforward?

-- 
hundred-and-one symptoms of being an internet addict:
230. You spend your Friday nights typing away at your keyboard

 /// 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.163

2006-11-14 Thread Bram Moolenaar

Patch 7.0.163
Problem:Can't retrieve the position of a sign after it was set.
Solution:   Add the netbeans interface getAnno command. (Xavier de Gaye)
Files:  runtime/doc/netbeans.txt, src/netbeans.c


*** ../vim-7.0.162/runtime/doc/netbeans.txt Sun May  7 16:58:43 2006
--- runtime/doc/netbeans.txtTue Nov 14 18:24:32 2006
***
*** 1,4 
! *netbeans.txt*  For Vim version 7.0.  Last change: 2006 Mar 09
  
  
  VIM REFERENCE MANUALby Gordon Prieur
--- 1,4 
! *netbeans.txt*  For Vim version 7.0.  Last change: 2006 Nov 14
  
  
  VIM REFERENCE MANUALby Gordon Prieur
***
*** 259,266 
  confusion happening again, netbeans_saved() has been renamed to
  netbeans_save_buffer().
  
! We are now at version 2.3.  For the differences between 2.2 and 2.3 search for
! 2.3 below.
  
  The messages are currently sent over a socket.  Since the messages are in
  plain UTF-8 text this protocol could also be used with any other communication
--- 259,266 
  confusion happening again, netbeans_saved() has been renamed to
  netbeans_save_buffer().
  
! We are now at version 2.4.  For the differences between 2.3 and 2.4 search for
! 2.4 below.
  
  The messages are currently sent over a socket.  Since the messages are in
  plain UTF-8 text this protocol could also be used with any other communication
***
*** 604,609 
--- 604,618 
TODO: explain use of partial line.
  
  getMark   Not implemented.
+ 
+ getAnno serNum
+   Return the line number of the annotation in the buffer.
+   Argument:
+   serNum  serial number of this placed annotation
+   The reply is:
+   123 lnumline number of the annotation
+   123 0   invalid annotation serial number
+   New in version 2.4.
  
  getModified   When a buffer is specified: Return zero if the buffer does not
have changes, one if it does have changes.
*** ../vim-7.0.162/src/netbeans.c   Tue Aug 29 17:28:56 2006
--- src/netbeans.c  Tue Nov 14 18:23:48 2006
***
*** 61,67 
  
  /* The first implementation (working only with Netbeans) returned 1.1.  The
   * protocol implemented here also supports A-A-P. */
! static char *ExtEdProtocolVersion = 2.3;
  
  static long pos2off __ARGS((buf_T *, pos_T *));
  static pos_T *off2pos __ARGS((buf_T *, long));
--- 61,67 
  
  /* The first implementation (working only with Netbeans) returned 1.1.  The
   * protocol implemented here also supports A-A-P. */
! static char *ExtEdProtocolVersion = 2.4;
  
  static long pos2off __ARGS((buf_T *, pos_T *));
  static pos_T *off2pos __ARGS((buf_T *, long));
***
*** 1269,1274 
--- 1269,1297 
(int)curwin-w_cursor.col,
pos2off(curbuf, curwin-w_cursor));
nb_reply_text(cmdno, text);
+ /* =*/
+   }
+   else if (streq((char *)cmd, getAnno))
+   {
+   long linenum = 0;
+ #ifdef FEAT_SIGNS
+   if (buf == NULL || buf-bufp == NULL)
+   {
+   nbdebug((null bufp in getAnno));
+   EMSG(E652: null bufp in getAnno);
+   retval = FAIL;
+   }
+   else
+   {
+   int serNum;
+ 
+   cp = (char *)args;
+   serNum = strtol(cp, cp, 10);
+   /* If the sign isn't found linenum will be zero. */
+   linenum = (long)buf_findsign(buf-bufp, serNum);
+   }
+ #endif
+   nb_reply_nr(cmdno, linenum);
  /* =*/
}
else if (streq((char *)cmd, getLength))
*** ../vim-7.0.162/src/version.cTue Nov  7 22:41:37 2006
--- src/version.c   Tue Nov 14 18:25:31 2006
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 163,
  /**/

-- 
A computer without Windows is like a fish without a bicycle.

 /// 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.164

2006-11-14 Thread Bram Moolenaar

Patch 7.0.164
Problem::redir @+ doesn't work.
Solution:   Accept @+ just like @*. (Yegappan Lakshmanan)
Files:  src/ex_docmd.c


*** ../vim-7.0.163/src/ex_docmd.c   Tue Nov  7 18:43:10 2006
--- src/ex_docmd.c  Tue Nov 14 20:17:42 2006
***
*** 8371,8376 
--- 8371,8377 
if (ASCII_ISALPHA(*arg)
  # ifdef FEAT_CLIPBOARD
|| *arg == '*'
+   || *arg == '+'
  # endif
|| *arg == '')
{
***
*** 8381,8386 
--- 8382,8388 
 (islower(redir_reg)
  # ifdef FEAT_CLIPBOARD
|| redir_reg == '*'
+   || redir_reg == '+'
  # endif
|| redir_reg == ''))
{
*** ../vim-7.0.163/src/version.cTue Nov 14 18:29:00 2006
--- src/version.c   Tue Nov 14 20:23:38 2006
***
*** 668,669 
--- 668,671 
  {   /* Add new patch number below this line */
+ /**/
+ 164,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
232. You start conversations with, Have you gotten an ISDN line?

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


Inserting date/text

2006-11-14 Thread David Woodfall
I would like to make a command that would insert at cursor todays date,
and also a command to insert some custom text.

In the help file it shows how to make a keybind to do this but I would
rather use a command - eg :date

Can this be done?

Thanks
-- 
I don't care for the Sugar Smacks commercial.  I don't like the idea of
a frog jumping on my Breakfast.
-- Lowell, Chicago Reader 10/15/82


Re: Inserting date/text

2006-11-14 Thread David Woodfall
On (10:30 14/11/06), David Woodfall [EMAIL PROTECTED] put forth the 
proposition:
 I would like to make a command that would insert at cursor todays date,
 and also a command to insert some custom text.
 
 In the help file it shows how to make a keybind to do this but I would
 rather use a command - eg :date
 
 Can this be done?

Ok I've just found the :command command but I'm having problems:

:command Date :read !date +%d-%b-%Y

This prints xxd-xxb-xxY

!date with no options works fine on it's own. I have tried putting the
options in  and '' but still no go.

 
 Thanks
 -- 
 I don't care for the Sugar Smacks commercial.  I don't like the idea of
 a frog jumping on my Breakfast.
   -- Lowell, Chicago Reader 10/15/82

-- 
At a recent meeting in Snowmass, Colorado, a participant from Los
Angeles fainted from hyperoxygenation, and we had to hold his head
under the exhaust of a bus until he revived.


Re: Inserting date/text

2006-11-14 Thread A.J.Mechelynck

David Woodfall wrote:

I would like to make a command that would insert at cursor todays date,
and also a command to insert some custom text.

In the help file it shows how to make a keybind to do this but I would
rather use a command - eg :date

Can this be done?

Thanks


(untested; requires strftime() function) (note all user-defined command names 
must start with an uppercase letter)


command -nargs=* -bar Date call InsertDate(q-args)
function InsertDate(format)
if ! exists('*strftime')
echoerr 'strftime() not defined'
return -1
endif
let f = a:format
if f == 
let f = '%c'
endif
exe normal a\C-R=strftime( . f . )\e
endfunction

then
:Date
will insert the current date and time in your locale-dependent default format; 
or

:Date %d %b %Y

will (today) insert

14 Nov 2006

I hope I'm not just doing your homework (this sounds like a classical exercise).

The simplest way to insert some custom text is to keep in a register:

let @w = David Woodfall 

then hit

wp

to insert your name at the cursor in Normal mode, or

^Rw

(where ^R means hit Ctrl-R) in Insert mode.


Best regards,
Tony.


Re: Inserting date/text

2006-11-14 Thread Tim Chase

I would like to make a command that would insert at cursor todays date,
and also a command to insert some custom text.

In the help file it shows how to make a keybind to do this but I would
rather use a command - eg :date


I've had mappings in the past for things like

inoremap f4 c-r=strftime('%c')cr

which allows you to hit F4 in insert mode and have the date 
inserted.  You can use a similar pattern if you need it at the 
command line:


:put =strftime('%c')

(you can use put! to put it on the line above rather than the 
line below the current one)


This gives you more cross-platform support than just shelling out 
to the OS's date command, as the output (and even behavior  
parameter format) of the OS's date command can vary widely.


-tim






[Fwd: Missing it.ascii.spl]

2006-11-14 Thread Fabio Rotondo
---BeginMessage---
Hi,

I am trying to use the spell checker in Vim 7, but when I write:

:set spell spelllang=it

I get the following error:

Warning: Cannot find word list it.latin1.spl or it.ascii.spl

Where can I grab those files?

Thanks,

Fabio

---End Message---


Re: search between two brackets

2006-11-14 Thread Ben K.



I have a long source code consisting of multiple modules wrapped in {}.
Sometimes I use * to find the next match. But I'd like to search only
within the same module or class that I started from. (which is wrapped
inside sub ... {})


Thanks all. It should be sufficient.


I am not sure exactly what sort of highlighting you want.
Since my purpose was not to go astray to another module, I just wondered 
if there can be some visual indication to tell me that I'm still in my { 
module }. Like flipping foreground and background of the rest of the file, 
or dimming the colors, etc.


But the provided answer should be sufficient.

Regards,

Ben K.
Developer
http://benix.tamu.edu


Re: When {rhs} contains a space

2006-11-14 Thread A.J.Mechelynck

Charles E Campbell Jr wrote:

A.J.Mechelynck wrote:


Ying Bian wrote:


Vimmers,

I tried to do nmap s :set spell!CR to use s in normal mode
to toggle spell checker.  If I run this in the interactive command line,
it is ok.  But when I put this in my .vimrc, it has a tricky problem:
Although it seems to function correctly by hitting s, every time the
cursor moves one character forward.  Looks as if a space was sent.

I have tried to replace   with space in :set spell!CR but with
on luck.



Are you sure you left no space at the end of the line, after the CR ?

:let @/ = ' ' will highlight all spaces (and :nohls will clear that 
highlight).


You can also use :exe 'nmap s :set invspellCR' (with the single 
spaces but without the double spaces) to make sure that you won't miss 
any extra spaces.


Hmm, how about

:set hls
/
(that's / space)


It works but it's less obvious in an email.



(and :nohls will clear the highlighting).  Alternatively,
:set list

will show ~s at the end of lines containing spaces, too.


:set list will replace tabs by ^I (two screen cells) unless 'listchars' has 
been set to include a tab: suboption, e.g. with


:set list listchars+=tab:\ \

which also ends in a space.



Regards,
Chip Campbell




Best regards,
Tony.


cindent without statement terminator?

2006-11-14 Thread Dave
Hi all,

I'm working with an embedded language (AMX Netlinx) that has (mostly) a C like 
syntax and conditional keywords. 

It doesn't have a ; statement terminator, though.

Cindent mostly works, but gets tripped up on conditional statements that aren't 
enclosed in braces due to the lack of the semicolon.

Is there a way to tell cindent/cinoptions to ignore the lack of a semicolon?  
Or do I have to write a custom indent file?

If option (b), is there a gentle introduction somewhere on the innards of the 
indent file?  I tried to use the javascript file as a template, but got a bit 
tripped up syntax issues.

Thanks for any pointers,
David


Re: Inserting date/text

2006-11-14 Thread David Woodfall
On (12:28 14/11/06), A.J.Mechelynck [EMAIL PROTECTED] put forth the 
proposition:
 David Woodfall wrote:
 I would like to make a command that would insert at cursor todays date,
 and also a command to insert some custom text.
 
 In the help file it shows how to make a keybind to do this but I would
 rather use a command - eg :date
 
 Can this be done?
 
 Thanks
 
 (untested; requires strftime() function) (note all user-defined command 
 names must start with an uppercase letter)
 
   command -nargs=* -bar Date call InsertDate(q-args)
   function InsertDate(format)
   if ! exists('*strftime')
   echoerr 'strftime() not defined'
   return -1
   endif
   let f = a:format
   if f == 
   let f = '%c'
   endif
   exe normal a\C-R=strftime( . f . )\e
   endfunction
 
 then
   :Date
 will insert the current date and time in your locale-dependent default 
 format; or
 
   :Date %d %b %Y
 
 will (today) insert
 
   14 Nov 2006
 
 I hope I'm not just doing your homework (this sounds like a classical 
 exercise).

Thanks for the ideas. No this isn't homework - today I was writing some
readmes and thought it would save some typing to make a command to print
 'Release date dd mmm '
 
 The simplest way to insert some custom text is to keep in a register:
 
   let @w = David Woodfall 
 
 then hit
 
   wp
 
 to insert your name at the cursor in Normal mode, or
 
   ^Rw
 
 (where ^R means hit Ctrl-R) in Insert mode.
 
 
 Best regards,
 Tony.

-- 
Avoid reality at all costs.


Re: When {rhs} contains a space

2006-11-14 Thread Charles E Campbell Jr

A.J.Mechelynck wrote:


Charles E Campbell Jr wrote:



(and :nohls will clear the highlighting).  Alternatively,
:set list

will show ~s at the end of lines containing spaces, too.



:set list will replace tabs by ^I (two screen cells) unless 
'listchars' has been set to include a tab: suboption, e.g. with


:set list listchars+=tab:\ \

which also ends in a space.




Sorry 'bout that:  try

set listchars=tab:-,trail:~,eol:$
set list

*that* will show trailing spaces as ~s.

Regards,
Chip Campbell






Re: Setting Up Debugging

2006-11-14 Thread Charles E Campbell Jr

Tom Purl wrote:


I'm having a problem with netrw, but before I can properly troubleshoot
it, I need to fix debugging.  What I would basically like to do is use Vim
normally (without having a bunch of debug messages pop up) while all of
the messages are written to a file.

Here's what I have in my ~/.vimrc:

   let verbosefile = /tmp/vim_debug.out
   set viminfo='50,1000,s100
   :verbose set viminfo?

I copied this set of commands a couple of months ago to help troubleshoot
a different problem.  Shouldn't these commands still work, or am I missing
something?
 

I suggest using the Dfunc/Decho/Dret debugging system already part of 
netrw.  Once you have the

plugin installed,

 vim netrw.vim
 :DechoOn
 :wq

The latest version of netrw uses DechoTabOn, which means that debugging 
output will go to a
separate tab.  You can save the resulting output to a file whenever you 
wish, and the display

won't be affected (other than seeing the presence of two tabs).

You can get the Decho plugin from:

   http://vim.sourceforge.net/scripts/script.php?script_id=120
-or-
   http://mysite.verizon.net/astronaut/vim/index.html#DECHO
   (this latter one is always the most up-to-date)

You'll need an up-to-date version of vimball to extract plugins that
I've generated since August 1, 2006:

http://vim.sourceforge.net/scripts/script.php?script_id=1502

 -or-   http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
see Vimball Archiver (the most up-to-date version is here)

You'll need to completely remove all older vestiges of vimball from your
runtimepath.  Under Linux, that usually means

   cd /usr/local/share/vim/vim70
   /bin/rm plugin/vimball*.vim autoload/vimball*.vim

Under Windows, check your runtimepath to determine where your vim 7.0's
runtime directories are:

   vim
   :echo rtp
   :q

should give you a clue.

Regards,
Chip Campbell



Re: Setting Up Debugging

2006-11-14 Thread Tom Purl
 I suggest using the Dfunc/Decho/Dret debugging system already part of
 netrw.  Once you have the
 plugin installed,

   vim netrw.vim
   :DechoOn
   :wq

 The latest version of netrw uses DechoTabOn, which means that debugging
 output will go to a
 separate tab.  You can save the resulting output to a file whenever you
 wish, and the display
 won't be affected (other than seeing the presence of two tabs).

 You can get the Decho plugin from:

 http://vim.sourceforge.net/scripts/script.php?script_id=120
 -or-
 http://mysite.verizon.net/astronaut/vim/index.html#DECHO
 (this latter one is always the most up-to-date)

 You'll need an up-to-date version of vimball to extract plugins that
 I've generated since August 1, 2006:

  http://vim.sourceforge.net/scripts/script.php?script_id=1502

   -or-   http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
  see Vimball Archiver (the most up-to-date version is here)

Thanks for the quick reply Dr. Chip!  I tried installing both the latest
version of netrw and Decho, but I'm seeing a weird problem.

Here's the process that I used to install these plugins:

vim plugin.vba.gz
so %

And here's what the plugins look like on the file system (Linux) after
running said process:

[EMAIL PROTECTED] ~/.vim $ find . -type f -name *Decho*
./doc/Decho.txt?[[[1
./plugin/Decho.vim?[[[1
./syntax/Decho.vim?[[[1
[EMAIL PROTECTED] ~/.vim $ find . -type f -name *netrw*
./doc/pi_netrw.txt?[[[1
./plugin/netrwPlugin.vim?[[[1
./syntax/netrw.vim?[[[1
./autoload/netrw.vim?[[[1
./autoload/netrwFileHandlers.vim?[[[1
./autoload/netrwSettings.vim?[[[1

Has anyone ever seen anything like this before?

Thanks again!

Tom Purl



Re: Setting Up Debugging

2006-11-14 Thread Tom Purl
Thanks for the quick reply Dr. Chip!  I tried installing both the latest
version of netrw and Decho, but I'm seeing a weird problem.

Here's the process that I used to install these plugins:

vim plugin.vba.gz
so %

And here's what the plugins look like on the file system (Linux) after
running said process:

[EMAIL PROTECTED] ~/.vim $ find . -type f -name *Decho*
./doc/Decho.txt?[[[1
./plugin/Decho.vim?[[[1
./syntax/Decho.vim?[[[1
[EMAIL PROTECTED] ~/.vim $ find . -type f -name *netrw*
./doc/pi_netrw.txt?[[[1
./plugin/netrwPlugin.vim?[[[1
./syntax/netrw.vim?[[[1
./autoload/netrw.vim?[[[1
./autoload/netrwFileHandlers.vim?[[[1
./autoload/netrwSettings.vim?[[[1

Has anyone ever seen anything like this before?


 Yes -- its due to an out-of-date vimball plugin.  You need to get an
 up-to-date version of vimball (v18 or later),
 and to remove any previous vimball remnants.

Ok, I just wanted to make sure.  My computer has been doing some weird
things lately, and I wanted to narrow it down.  Also, it's impossible to
search for the term [[[1 in Google, so it was hard for me troubleshoot
*that* problem.

Thanks again!

Tom Purl



Re: yank and put 'over' instead of 'insert'

2006-11-14 Thread Troy Piggins
* A.J.Mechelynck [EMAIL PROTECTED] :
 Troy Piggins wrote:
 I use 'R' replace mode when doing, for example, ascii art etc
 because it allows me to change characters without affecting the
 layout of the rest of the window/page.
 
 But if I want to yank a section using visual or visual block, is
 there a way to put 'p' that block in without affecting the
 layout?  The way I've been doing it, the rest gets pushed along.
 
 Use visual again, and the put will replace the selection: see :help v_p.

Thanks for the quick response Tony!

That works if the 2nd visual selection is the same size, but if
different size text to the right is moved along.

Also, if I want to delete a block to move it instead of copy it,
text to the right of the deleted block is shifted left.  Is there
a way around that?

-- 
Troy Piggins