Loading ...
Sorry, an error occurred while loading the content.

Create mapping with '-c' command-line option

Expand Messages
  • Jean-Rene David
    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 when
    Message 1 of 2 , Feb 25, 2011
    • 0 Attachment
      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?

      --
      JR

      --
      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
    • ZyX
      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
      Message 2 of 2 , Feb 25, 2011
      • 0 Attachment
        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?
      Your message has been successfully submitted and would be delivered to recipients shortly.