Friday, February 25, 2011

Re: Create mapping with '-c' command-line option

Reply to message «Create mapping with '-c' command-line option»,
sent 18:52:13 25 February 2011, Friday
by Jean-Rene David:

You should be sure that 'compatible' is not set and `<' flag is not in
'cpoptions'. You may also try

vim --cmd "nnoremap <special> ZZ :qa<CR>"

If you are in zsh, be sure that nobody redefined accept-line ZLE widget and that
<C-m> is binded to accept-line: I, for example, use accept-line to be able to
write «:h 'cpoptions'» (in zsh, not in vim) and launch vim with a proper help
topic (accept-line escapes «'» signs before launching a command).

Original message:
> Hello,
>
> I'm writing a little shell function that opens vim with two files in a
> split window. I'm trying to define the following mapping:
>
> map ZZ :qa<cr>
>
> when invoking vim, like so:
>
> function_foo() {
> vim -c "map ZZ :qa<cr>" -o file1 file2
> }
>
> However once I'm in that vim session, the '<cr>' sequence was
> interpreted as four characters instead of as 'start entered command', so
> my mapping is useless.
>
> Is there something I'm missing about the way vim interprets commands
> passed using the '-c' option?

No comments:

Post a Comment