Wednesday, October 27, 2010

Re: difference command line and menu?

On Oct 26, 7:11 am, rameo <rai...@gmail.com> wrote:

> John exactly the same command as in the vimrc file.
>
> :'<,'>s/^\([-*]\|\d*\.\)\s*\l/\U&/gc<CR>

We're at cross purposes here. menu.vim is run a part of gui
initialization, before the file being edited is loaded. If I put
exactly

:'<,'>s/^\([-*]\|\d*\.\)\s*\l/\U&/gc<CR>

in menu.vim, I get an error dialogue box saying:

Error detected while processing /home/john/.vim/menu.vim:
line 18:
E20: Mark not set

Indeed, the same applies to the .vimrc.
I assumed that you'd put in menu.vim something to get a menu entry
that would do the search and replace, something like (split over two
lines because google groups will split it anyway):

anoremenu 20.305 &Edit.Capitalize\ &List
\ :'<,'>s/^\([-*]\\|\d*\.\)\s*\l/\U&/gc<CR>

Now, doing this, I found that the backslash before the | had to be
doubled. However, for a mapping in the vimrc file, the same applies:

map <F4> :'<,'>s/^\([-*]\\|\d*\.\)\s*\l/\U&/gc<CR>

This shows there is indeed a difference between the menu entry and the
mapping, to do with the range given with the '< and '> marks; using
the mapping as above fails if the visual selection is still displayed,
because the marks are entered twice. You'd need another mapping for
visual mode:

vmap <F4> :s/^\([-*]\\|\d*\.\)\s*\l/\U&/gc<CR>

However, I'm not sure I understand what you've done, or are trying to
do. Is the problem with the | the incompatibility you're referring
to? That occurs because | is used to have multiple commands on the
command line, see :help map_bar, and there's various vi-compatible
kludges.

Regards, John

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: