Thursday, March 1, 2012

Re: abbreviation does not work after map

On 02/29/12 22:27, Yichao Zhou wrote:
>> You might try
>>
>> :inoremap <cr> <c-]><c-g>u<cr>
>
> But if the word before the cursor is not a abbreviation, it
> will insert a literal ^], which is not an ideal solution.

This is strange. I performed the following:

1) put the following 2 lines in temp/c.vim
"""
iab aa American Airlines
inoremap <cr> <c-]><c-g>u<cr>
"""

2) started vim with "vi -u NONE"

3) issued ":so temp/c.vim" to load the two lines

4) entered the text "When aa" followed by <cr> followed by "filed
for" and hit <cr> again.

It worked as expected (expanding the text on the first line, and
not including a literal "^]" in either line). Unfortunately, the
"c-g>u" didn't drop an undo point.

When I performed the same steps, but issued a ":set nocp" between
steps 2 and 3, it inserted the "^]" in my text. The mere
presence of a .vimrc file (even an empty one) triggered 'nocp',
causing those to fail. The same happens if I put a literal "^]"
in my mapping instead of using "<c-]>" notation.

So I'm suspecting there are two bugs here unless I can be pointed
to documentation saying otherwise:

1) when 'nocp' is set, using <c-]> in a mapping doesn't expand
abbreviations.

2) when 'cp' is set, i_CTRL-G_u doesn't perform as advertised in
the help (the help on i_CTRL-G_u doesn't give any caveat
regarding cp/nocp behavior differences)

There might be some side-referenced aspect in ":h cpo-k" and ":h
cpo-<", but I would expect that to fail in the opposite direction.

-tim

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