A few people complained that Insert mode completion doesn't work as
expected, especially when 'completeopt' contains "longest". This is
mostly because Vim continues completion mode even when typing a non-word
character.
Below is a patch that changes the behavior. When completing a word with
CTRL-N and typing a non-word character Vim stops completion mode. Thus
if you type something like this:
asdfasdf
asd<C-N>:asd<C-N>
Previously the second <C-N> would not work, because you are completing
"asdfasdf:asd". After the patch typing the ":" stops completion mode, so
that the second <C-N> complets "asd".
Let me know what you think.
*** ../vim-7.1.135/src/edit.c Thu Sep 13 18:25:08 2007
--- src/edit.c Wed Oct 3 15:54:57 2007
***************
*** 129,134 ****
--- 129,135 ----
static void ins_ctrl_x __ARGS((void));
static int has_compl_option __ARGS((int dict_opt));
+ static int ins_compl_accept_char __ARGS((int c));
static int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u
*fname, char_u **cptext, int cdir, int flags, int adup));
static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
static void ins_compl_longest_match __ARGS((compl_T *match));
***************
*** 754,761 ****
continue;
}
! /* A printable, non-white character: Add to "compl_leader". */
! if (vim_isprintc(c) && !vim_iswhite(c))
{
ins_compl_addleader(c);
continue;
--- 755,763 ----
continue;
}
! /* A non-white character that fits in with the current
! * completion: Add to "compl_leader". */
! if (!vim_iswhite(c) && ins_compl_accept_char(c))
{
ins_compl_addleader(c);
continue;
***************
*** 2050,2055 ****
--- 2052,2080 ----
}
EMSG(_(e_internal));
return FALSE;
+ }
+
+ /*
+ * Return TRUE when character "c" is part of the item currently being
+ * completed. Used to decide whether to abandon complete mode when the menu
+ * is visible.
+ */
+ static int
+ ins_compl_accept_char(c)
+ int c;
+ {
+ if (ctrl_x_mode & CTRL_X_WANT_IDENT)
+ return vim_isIDc(c);
+ switch (ctrl_x_mode)
+ {
+ case CTRL_X_FILES:
+ return vim_isfilec(c);
+ case CTRL_X_WHOLE_LINE:
+ case CTRL_X_CMDLINE:
+ case CTRL_X_OMNI:
+ return vim_isprintc(c);
+ }
+ return vim_iswordc(c);
}
/*
--
FIRST VILLAGER: We have found a witch. May we burn her?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---