我现在使用Vim很多年了,但我还是不知道如何在没有按任何快捷键的情况下启用autopopup字典建议(如notepad ++或google android键盘)来输入文本。
这些是我在vimrc中的选项:
set completeopt=longest,menuone
set omnifunc=syntaxcomplete#Complete
简而言之,我想要的是:
1)键入时只在autopopup中提供字典建议
2)仅在supertab中使用缓冲字建议(使用tab键)
(但是......没有包含缓冲区名称)
我怎样才能获得这个?
答案 0 :(得分:2)
/usr/share/dict/american-english
,或者只设置自己的文件: :set dictionary+=/usr/share/dict/american-english
并且在插入模式下字典完成的快捷方式是 CTRL-X CTRL-K ,您需要添加以下设置:
:set noshowmode
:set completeopt+=noinsert
:autocmd CursorHoldI * call feedkeys("\<c-x>\<c-k>")
:set updatetime=500
SuperTabSetDefaultCompletionType
函数(实际上是默认值)来限制Supertab插件仅弹出缓冲区字词: :call SuperTabSetDefaultCompletionType("<c-x><c-n>")
但你仍然需要在 TAB 之前按 CTRL-X 。
:NeoCompleteDisable
:help ins-completion
(...) Completion can be done for: 1. Whole lines i_CTRL-X_CTRL-L 2. keywords in the current file i_CTRL-X_CTRL-N 3. keywords in 'dictionary' i_CTRL-X_CTRL-K 4. keywords in 'thesaurus', thesaurus-style i_CTRL-X_CTRL-T 5. keywords in the current and included files i_CTRL-X_CTRL-I 6. tags i_CTRL-X_CTRL-] 7. file names i_CTRL-X_CTRL-F 8. definitions or macros i_CTRL-X_CTRL-D 9. Vim command-line i_CTRL-X_CTRL-V 10. User defined completion i_CTRL-X_CTRL-U 11. omni completion i_CTRL-X_CTRL-O 12. Spelling suggestions i_CTRL-X_s 13. keywords in 'complete' i_CTRL-N
修改强>
这与此答案下方的评论有关:这是一个很小的脚本PopUpDict.vim
(可以改进)我编码后会在输入 3 后自动弹出字典中匹配的字词字符,使您能够在键入ctrl-x
tab
后弹出匹配的缓冲区关键字:(较新版本的vim&gt; = 7.4)
set dictionary+=/usr/share/dict/american-english
set completeopt+=noinsert
set cmdheight=2
call SuperTabSetDefaultCompletionType("<c-x><c-n>")
NeoCompleteDisable
augroup Main
autocmd!
autocmd InsertCharPre * call <SID>PopUpDict()
augroup END
let s:count=0
function! s:PopUpDict()
let AsciiCode=char2nr(v:char)
if (AsciiCode <=# 122 && AsciiCode >=# 97) || (AsciiCode <=# 90 && AsciiCode >=# 65)
let s:count+=1
if s:count >=# 3
call feedkeys("\<c-x>\<c-k>")
endif
else
let s:count=0
endif
endfunction