如何防止 <c-u> 删除 vim 中 completefunc 中的行

How do I prevent <c-u> from deleting the line in completefunc in vim

我有一个 completefunc returns "Some string 1 ", "Some string 2" 但每次出现完成菜单时它都会删除我当前的所有行。除非我回到原来的位置,否则我会丢失以前的文字。我尝试重新映射什么也不做,它继续删除我的行。我希望它表现得更像当你想用 .

完成文件名时

我不希望它这样做。

我希望它这样做。

问题似乎不是 Ctrl+U 被解释为“清除行首”命令,而是您的 'completefunc' 没有正确实施“findstart”部分。

参见:help complete-functions

On the first invocation the arguments are:

  • a:findstart: 1
  • a:base: empty

The function must return the column where the completion starts. It must be a number between zero and the cursor column col('.'). This involves looking at the characters just before the cursor and including those characters that could be part of the completed item. The text between this column and the cursor column will be replaced with the matches.

如果您的函数未实现此部分,则可能 Vim 得到“0”,这表示行的开头。