I have been unhappy about the longest common text of auto-complete
provided by VIM for a long long time.
I try to find a good solution on the Internet, but all I got is
Put
completeopt += menuone,longest
in your .vimrc
It does provide a longest common text of auto-complete FOR THE FIRST
TIME. After I type one more character and press <tab>, it just
starts to move on the popup menu. No more longest common text of all
matches anymore.
To work around this, I hacked the
SuperTab
to provide longest common text.
Here is how:
- open supertab.vim in your /plugin directory
- find function! s:SuperTab(command)
- change the code
" handle 'context' completion.
if b:complType == 'context'
let complType = s:ContextCompletion()
if complType == ''
exec "let complType = \"" .
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
endif
return complType . key
endif
to
" handle 'context' completion.
if b:complType == 'context'
let complType = s:ContextCompletion()
if complType == ''
exec "let complType = \"" .
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
endif
if pumvisible()
return "\<ESC>a" . complType . key
else
return complType . key
endif
endif
The idea is simple. Just close the popup menu each time users press <tab>
0 comments:
Post a Comment