自动弹出的字典建议 [英] Dictionary suggestions in autopopup
问题描述
我使用 Vim 已经很多年了,但我仍然不知道如何在启用自动弹出字典建议的情况下(例如在 notepad++ 或 google android 键盘中)在不按任何快捷键的情况下键入文本.
这些是我在 vimrc 中的选项:
set completeopt=longest,menuone设置omnifunc=syntaxcomplete#完成
简而言之,我想要的是:
1) 键入时自动弹出的仅字典建议.
2) 仅在 supertab 中缓冲单词建议(使用 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 * 调用 feedkeys("<c-x><c-k>"):设置更新时间=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
这篇关于自动弹出的字典建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- If you are using Linux you can set the existing english dictionary to