Tim's Blog

Setting up Vim omnicomplete with Qt4, QGIS

Qt4 and QGIS Vim Omnicomplete (adapted from this page and this page) I’m assuming ubuntu is in use here… Create a ~/.ctags

--c++-kinds=+p
--fields=+iaS
--extra=+q

Next create a ctags file for Qt4 (rerun if you upgrade Qt)

ctags -f ~/.vim/qt4tags -R /usr/include/qt4/

Alternatively you can inline the ctags options (instead of using a .ctags file) like this:

ctags -f ~/.vim/qt4tags -R --c++-kinds=+p --fields=+iaS --extra=+q /usr/include/qt4/

While you are in your ~/.vim directory, place C++ completion files there too. Grab them from here and unzip them into your ~/.vim dir.

Now add to your .vimrc:

set tags=tags
"for when programming in build dir
set tags+=../tags
"find qt4 tags for autocomplete
set tags+=~/.vim/qt4tags
"bind the key for omnicomplete to ctrl-space
inoremap  
filetype on
filetype plugin on
set nocp
"as an alternative to keybinding above, the commands below
"will cause the omnicomplete to activate automatically
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#CompleteCpp

Run in project root:

ctags -R .

Note that you will need to disable any other apps usng the Ctrl-space keybinding for obvious reasons.


To Tumblr, Love PixelUnion