History Report a problem
Article Edit this page Discussion

Autocomplete with TAB when typing words

From Vim Tips Wiki

Jump to: navigation, search
 

Tip 566Previous TipNext Tip

Created: September 30, 2003 Complexity: basic Author: mohsin Minimum version: 6.0 Karma: 142/39 Imported from: Tip#566


"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/dict/words"

[edit] References

[edit] Comments

 

Even easier than <Tab> is to have words completed automatically. There are some drawbacks to this, but the word_complete.vim plugin works pretty well.


To use the dictionary, add 'k' to your ':set complete'. For language keywords (tags), also add ']'. See :help 'complete'.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Autocomplete with TAB when typing words"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation