How to insert a newline in a map value?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to insert a newline in a map value?

Hiroshi Iwatani
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*
---------------------
Reply | Threaded
Open this post in threaded view
|

Re: How to insert a newline in a map value?

Chris Allen
On 01/10/05, Hiroshi Iwatani <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to insert a newline in a map value?

Tim Chase-2
>>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







Reply | Threaded
Open this post in threaded view
|

Re: How to insert a newline in a map value?

A.J.Mechelynck
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.