在autopopup中的词典建议 [英] Dictionary suggestions in autopopup
问题描述
我使用Vim多年,但是我仍然不知道如何使用autopopup字典建议键入文本(如notepad ++或者google android键盘),而不需要任何快捷键。
这些是我在vimrc中的选择:
set completeopt = longest,menuone
set omnifunc = syntaxcomplete#完成
简而言之,我想要的是:
1)只有字典
2)只有超文本中的缓冲词建议(使用tab键)
(但不包括缓冲区名称)
如何获得这个?
- Linux可以将现有的英文字典设置为
/ 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
- 您可以限制
I use Vim for many years now but I still don't know how to type text with autopopup dictionary suggestions enabled (like in notepad++ or google android keyboard) without pushing any shortcut key.
These are my options in vimrc:
set completeopt=longest,menuone set omnifunc=syntaxcomplete#Complete
In short what I want is:
1) Only dictionary suggestion in autopopup while typing.
2) Only buffer words suggestion in supertab (using tab key)
(but..without the buffer names included)How can I obtain this?
解决方案- If you are using Linux you can set the existing english dictionary to
/usr/share/dict/american-english
or just set your own file:
:set dictionary+=/usr/share/dict/american-english
and as the shortcut for dictionary completion in insert mode is CTRL-X CTRL-K you need to add these settings:
:set noshowmode :set completeopt+=noinsert :autocmd CursorHoldI * call feedkeys("\<c-x>\<c-k>") :set updatetime=500
- You can restrict the Supertab plugin to popup only the buffer words by calling
SuperTabSetDefaultCompletionType
function (which is actually the default one):
:call SuperTabSetDefaultCompletionType("<c-x><c-n>")
But you still need to press CTRL-X before TAB.
- Disable the NeoComplete plugin
: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
Edit:
This is related to comments below this answer: It is a tiny script
PopUpDict.vim
(it can be improved) that I coded which pop up automatically the matched words in dictionary after typing 3 characters and which give you the ability to pop up the matched buffer keywords after typingctrl-x
tab
: (newer version of vim >= 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
Demo
这篇关于在autopopup中的词典建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- If you are using Linux you can set the existing english dictionary to