Wednesday, August 10, 2011

Re: z doesn't work in a function

On Aug 10, 7:09 am, sinbad <sinbad.sin...@gmail.com> wrote:
> hi,
>
> the following statement is not working inside a vim function.
> any clue ?
>
> silent normal! z<CR>
>

Because you're feeding in 4 characters, '<', 'C', 'R', '>' instead of
the intent, which is doubtless to feed in an actual <CR> character.
There are at least two ways to do this in a normal command:

1. silent exec "normal! z\<CR>"
2. silent normal! z^M (where the ^M is not the two characters, but
rather the result of typing CTRL-V followed by an actual <CR> to
insert the byte literally)

The first is probably slightly cleaner.

The special <Key> syntax pretty much only works in mappings. For use
in strings, it must be escaped as shown (and in double-quotes, not
single-quotes, which will take the '\' literally as well).

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