-3

我的.vimrc包含:

set wildmenu                    " show list instead of just completing
set wildmode=list:longest,full  " command <Tab> completion, list matches, then longest common part, then all.
set wildignore+=.cache,.gem,.ivy2,.extras.bash,.themes
set wildignore+=.subversion,.subversion_IDEA
set wildignore+=.Trash
set wildignore+=Desktop,Documents,Downloads
set wildignore+=Library,Movies,Pictures
set wildignore+=spf13vim2
set wildignore+=.CFUserTextEncoding,.DS_Store
set wildignore+=.bash_history,.extra.bash,.irb-history
set wildignore+=.lesshst,.mysql_history,.pry_history
set wildignore+=.reviewboard-cache,.rnd,.sbt.cache.lock
set wildignore+=.scala_history,.sqlite_history,.viminfo
set wildignore+=*.o,*.obj,.git,vendor/rails/**,vendor/gems/**
set wildignore+=*.swp

你可以在这里找到我的完整 vimrc 。当我在 vim 中编辑文件时,点击tab会产生空格,但不会自动完成。

4

2 回答 2

5

什么?

wildmenu 是在命令行上尝试制表符补全时出现的菜单:

在此处输入图像描述

它与插入模式完成完全无关,您问题中的设置永远不会帮助您在编辑文件时完成任何事情。

事实胜于推测:你应该养成阅读 Vim 内部文档的习惯。如果您花时间阅读它的第一句话:h 'wildmenu'就会消除您的困惑:

When 'wildmenu' is on, command-line completion operates in an enhanced mode.

盲目地从随机的互联网来源复制设置会让你一事无成。阅读:help.

于 2013-04-08T05:05:56.733 回答
-2

我不知道这是否有必要,但是在我将它添加到我的之后,制表符完成工作.vimrc

function! Smart_TabComplete()
  let line = getline('.')                         " current line

  let substr = strpart(line, -1, col('.')+1)      " from the start of the current
                                                  " line to one character right
                                                  " of the cursor
  let substr = matchstr(substr, "[^ \t]*$")       " word till cursor
  if (strlen(substr)==0)                          " nothing to match on empty string
    return "\<tab>"
  endif
  let has_period = match(substr, '\.') != -1      " position of period, if any
  let has_slash = match(substr, '\/') != -1       " position of slash, if any
  if (!has_period && !has_slash)
    return "\<C-X>\<C-P>"                         " existing text matching
  elseif ( has_slash )
    return "\<C-X>\<C-F>"                         " file matching
  else
    return "\<C-X>\<C-O>"                         " plugin matching
  endif
endfunction

inoremap <tab> <c-r>=Smart_TabComplete()<CR>
于 2013-04-08T02:58:04.513 回答