Add this to your .vimrc:
autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType c set omnifunc=ccomplete#Complete
Try it out:
$ touch index.html $ vim index.html type: <ht[CTRL-X][CTRL-O]
autocompleteccsshtmljavascriptphppythonvimvimrcxml
Put this into ~/.vimrc:
fun! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfun
fun! ShiftInsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<s-tab>"
else
return "\<c-n>"
endif
endfun
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-r>=ShiftInsertTabWrapper()<cr>
:set dictionary+=dict.file
:set dictionary+=%
:set iskeyword+=:
:set complete+=k
autocompletionconfigurationeditorssettingsvivimvimrc
Some recommended settings for your ~/.vimrc because we all hate tabs (right?):
set sw=4 set ts=4 set sts=4 set expandtab syntax on
configurationeditorsindentationvimvimrc
If you like working with a dark background and enjoy syntax highlighting but hate the navy blue on black, try putting the following line in your ~/.vimrc:
set background=dark
backgroundconfigurationeditorshighlightingsyntaxvimvimrc
On a new windows install I'll always drop in these entries for startup configuration:
" general settings set sw=4 set ts=4 set et set nohls " lhs comments map ,# :s/^/#/<CR> map ,/ :s/^/\/\//<CR> map ,> :s/^/> /<CR> map ," :s/^/\"/<CR> map ,% :s/^/%/<CR> map ,! :s/^/!/<CR> map ,; :s/^/;/<CR> map ,- :s/^/--/<CR> map ,c :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR> " wrapping comments map ,* :s/^\(.*\)$/\/\* \1 \*\//<CR> map ,( :s/^\(.*\)$/\(\* \1 \*\)/<CR> map ,< :s/^\(.*\)$/<!-- \1 -->/<CR> map ,d :s/^#//<CR> " screen location & dimensions winpos 50 50 set lines=30 set columns=120 " squirrel away backup files set bdir=c:/backups set directory=c:/backups
Note: You'll need to create the backup folder before you can use it.
gvimvimvimrc