Hi Tim!
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
> abbreviations.
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™
diff --git a/src/edit.c b/src/edit.c
--- a/src/edit.c
+++ b/src/edit.c
@@ -1442,13 +1442,13 @@
Insstart_blank_vcol = get_nolist_virtcol();
}
- if (vim_iswordc(c) || !echeck_abbr(
+ if (vim_iswordc(c) || (!echeck_abbr(
#ifdef FEAT_MBYTE
/* Add ABBR_OFF for characters above 0x100, this is
* what check_abbr() expects. */
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) :
#endif
- c))
+ c) && c != Ctrl_RSB)) /* don't insert ^] */
{
insert_special(c, FALSE, FALSE);
#ifdef FEAT_RIGHTLEFT
diff --git a/src/getchar.c b/src/getchar.c
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -4352,7 +4352,7 @@
if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */
return FALSE;
- if ((KeyNoremap & (RM_NONE|RM_SCRIPT)) != 0)
+ if (((KeyNoremap & (RM_NONE|RM_SCRIPT)) != 0) && c != Ctrl_RSB)
/* no remapping implies no abbreviation */
return FALSE;
>
> 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.
see above
regards,
Christian
--
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