我的.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 here。当我在vim中编辑文件时,点击tab
会产生空格,但没有自动完成。
答案 0 :(得分:5)
什么?
wildmenu是在命令行上尝试完成选项卡时显示的菜单:
完全与插入模式完成无关,您的问题中的设置将从不帮助您在编辑文件时完成任何操作。
事实胜于猜测:你应养成阅读Vim内部文档的习惯。如果您花时间阅读它,:h 'wildmenu'
的第一句话就会消除您的困惑:
When 'wildmenu' is on, command-line completion operates in an enhanced mode.
盲目地从随机互联网资源中复制设置将无处可寻。阅读:help
。
答案 1 :(得分:-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>