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

How to insert a newline in a map value?

Expand Messages
  • Hiroshi Iwatani
    In my .vimrc imap r or imap doesn t insert a newline at the r or position. How could we get
    Message 1 of 4 , Sep 30, 2005
    • 0 Attachment
      In my .vimrc

      imap <F4> <BLOCKQUOTE>\r<PRE><CODE>
      or
      imap <F4> <BLOCKQUOTE><CR><PRE><CODE>

      doesn't insert a newline at the \r or <CR> position.

      How could we get the newline?

      Thanks in advance.

      --
      Hiroshi Iwatani

      *stop cruelty* Annual number of institutionally euthanized cats and dogs
      including kittens and puppies: US 5 million, JP 500 thousand. How about
      your country? *for our better karma*
      ---------------------
    • Chris Allen
      ... Try this: imap ^V Where ^V is a literal, typed control-v and is you hitting the enter key. For more details see
      Message 2 of 4 , Oct 1, 2005
      • 0 Attachment
        On 01/10/05, Hiroshi Iwatani <HGA03630@...> wrote:
        > In my .vimrc
        >
        > imap <F4> <BLOCKQUOTE>\r<PRE><CODE>
        > or
        > imap <F4> <BLOCKQUOTE><CR><PRE><CODE>
        >
        > doesn't insert a newline at the \r or <CR> position.

        Try this:

        imap <F4> <BLOCKQUOTE>^V<ENTER><PRE><CODE>

        Where ^V is a literal, typed control-v and <ENTER> is you hitting the
        enter key. For more details see :help c_CTRL-V for details on why
        this works.

        HTH,
        Chris Allen
      • Tim Chase
        ... Strange that the Hiroshi s second one didn t work for him, as it worked just fine for me. Chris s use of ^V^M worked fine for me as well. The only thing I
        Message 3 of 4 , Oct 1, 2005
        • 0 Attachment
          >>imap <F4> <BLOCKQUOTE>\r<PRE><CODE>
          >>or
          >>imap <F4> <BLOCKQUOTE><CR><PRE><CODE>
          >>
          >>doesn't insert a newline at the \r or <CR> position.
          >
          > Try this:
          >
          > imap <F4> <BLOCKQUOTE>^V<ENTER><PRE><CODE>
          >
          > Where ^V is a literal, typed control-v and <ENTER> is you hitting the
          > enter key. For more details see :help c_CTRL-V for details on why
          > this works.

          Strange that the Hiroshi's second one didn't work for him, as it
          worked just fine for me. Chris's use of ^V^M worked fine for me
          as well.

          The only thing I found that triggered a strange behavior was
          having the 'nocp' option set. With a vimrc file *only*
          containing the above <CR> mapping, I simply got the text "<F4>"
          in my document in insert mode. however, if my vimrc file
          consisted of these *two* lines

          set nocp
          imap <F4> <BLOCKQUOTE><CR><PRE><CODE>

          then it worked just fine. That's in Win32 gvim v6.1, but YMMV.

          -tim
        • A. J. Mechelynck
          ... Vim is supposed to set nocompatible if it finds a user vimrc (~/.vimrc, ~/_vimrc, or [on Windows] $VIM/_vimrc but not $VIM/vimrc). The behaviour of
          Message 4 of 4 , Oct 1, 2005
          • 0 Attachment
            Tim Chase wrote:
            >>> imap <F4> <BLOCKQUOTE>\r<PRE><CODE>
            >>> or
            >>> imap <F4> <BLOCKQUOTE><CR><PRE><CODE>
            >>>
            >>> doesn't insert a newline at the \r or <CR> position.
            >>
            >> Try this:
            >>
            >> imap <F4> <BLOCKQUOTE>^V<ENTER><PRE><CODE>
            >>
            >> Where ^V is a literal, typed control-v and <ENTER> is you hitting the
            >> enter key. For more details see :help c_CTRL-V for details on why
            >> this works.
            >
            > Strange that the Hiroshi's second one didn't work for him, as it worked
            > just fine for me. Chris's use of ^V^M worked fine for me as well.
            >
            > The only thing I found that triggered a strange behavior was having the
            > 'nocp' option set. With a vimrc file *only* containing the above <CR>
            > mapping, I simply got the text "<F4>" in my document in insert mode.
            > however, if my vimrc file consisted of these *two* lines
            >
            > set nocp
            > imap <F4> <BLOCKQUOTE><CR><PRE><CODE>
            >
            > then it worked just fine. That's in Win32 gvim v6.1, but YMMV.
            >
            > -tim

            Vim is supposed to set 'nocompatible' if it finds a user vimrc
            (~/.vimrc, ~/_vimrc, or [on Windows] $VIM/_vimrc but not $VIM/vimrc).

            The behaviour of <> in mappings (and menus) depends on the presence or
            absence of the < flag in 'cpoptions' (q.v.).

            BTW, Tim, don't you think it might be time to upgrade? 6.2 has come and
            gone with hundreds of bug fixes, and 6.3.090 is available since today.
            Just my 0,02€ of course.


            Best regards,
            Tony.
          Your message has been successfully submitted and would be delivered to recipients shortly.