Hi Tim! ... I think, this is because of the cpo option including the
Message 1 of 1
, Mar 2, 2012
On Do, 01 Mär 2012, Tim Chase wrote:
> 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.
I think, this is because of the 'cpo' option including the '<' char (see
:h cpo-<) which means, vim doesn't recognize <c-g>u as breaking the undo
sequence. If you set cpo-=< cpo-=u it should work however.
> 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
This seems like a bug, and here is a patch. I am not sure, this is the
correct way to approach this bug, but it works for me™
- if (vim_iswordc(c) || !echeck_abbr(
+ if (vim_iswordc(c) || (!echeck_abbr(
/* Add ABBR_OFF for characters above 0x100, this is
* what check_abbr() expects. */
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) :
+ c) && c != Ctrl_RSB)) /* don't insert ^] */
insert_special(c, FALSE, FALSE);
diff --git a/src/getchar.c b/src/getchar.c
@@ -4352,7 +4352,7 @@
if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */
- if ((KeyNoremap & (RM_NONE|RM_SCRIPT)) != 0)
+ if (((KeyNoremap & (RM_NONE|RM_SCRIPT)) != 0) && c != Ctrl_RSB)
/* no remapping implies no abbreviation */
> 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.
Die Ohnmacht des Menschen in Mäßigung oder Hemmung der Affekte nenne
ich Knechtschaft; denn der von seinen Affekten abhängige Mensch ist
nicht Herr über sich selbst, sondern dem Schicksal untertan.
-- Baruch de Spinoza (Nachlaß)
You received this message from the "vim_dev" 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
Your message has been successfully submitted and would be delivered to recipients shortly.
Changes have not been saved
Press OK to abandon changes or Cancel to continue editing
Your browser is not supported
Kindly note that Groups does not support 7.0 or earlier versions of Internet Explorer.
We recommend upgrading to the latest Internet Explorer, Google Chrome, or Firefox. If you are using IE 9 or later, make sure you turn off Compatibility View.