aglasspool

Vim + Autocompletion

In Uncategorized on April 19, 2010 at 8:14 pm

The following pasted into your vimrc file will auto-complete on pressing tab.
It will offer you suggestions based on your current text first, then on dictionary entries.
I also had to enter this in my buffer:

:set complete-=k complete+=k

put this in vimrc:

“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>”
else
return “\<Tab>”
endif
endfunction
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
set dictionary+=/usr/share/dict/words

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.