Learning Vim: Tab Autocomplete
I recently made the switch to Vim mainly due to my frustrations with folder navigation in Geany. When pairing with my colleagues, seeing them move through folders and changing code made me feel like I was programming with the handbrakes on.
- "Use TAB to complete when typing words, else inserts TABs as usual.
- "Uses dictionary and source files to find matching words to complete.
-
- "See help completion for source,
- "Note: usual completion is on <c-n> but more trouble to press all the time.
- "Never type the same word twice and maybe learn a new spellings!
- "Use the Linux dictionary when spelling is in doubt.
- "Window users can copy the file to their machine.
- function! Tab_Or_Complete()
- if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
- return "\</c-n><c-n>"
- else
- return "\<tab>"
- endif
- endfunction
- :inoremap </tab><tab> <c-r>=Tab_Or_Complete()<cr>
- :set dictionary="/usr/dict/words"</cr></c-r></tab></c-n>
Category: vim



Leave a Comment :
Leave a Comment