ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

The following .vimrc snippet is mostly from here. The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of your ros package for the ctags command (this assumes the current working dir of vim is your projects directory, which btw also allows you to use :mak).

map <F12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"This is to tag the include for ros packages the current project depends on
map <F11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<CR>
"map <F11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<CR>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion

Beware of the bad syntax highlighting, apparently " is not seen as comment starter.

The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).

The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of your ros package for the ctags command (this assumes the current working dir of vim is your projects directory, which btw also allows you to use :mak).:mak). With this, hitting F11 will generate completion tags for your project.

map <F12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"This is to tag the include for ros packages the current project depends on
map <F11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<CR>
"map <F11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<CR>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion

Beware of the bad syntax highlighting, apparently " is not seen recognized as comment starter.

The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).

The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of your ros package for the ctags command (this assumes the current working dir of vim is your projects directory, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your project.

map <F12> <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
.<cr>
"This is to tag the include for ros packages the current project depends on
map <F11> <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<CR>
cflags-only-I`<cr>
"map <F11> <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<CR>
~/local/usr/include/<cr>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion
 

Beware of the bad syntax highlighting, apparently " is not recognized as comment starter.

click to hide/show revision 4
Too long answer to a comment to fit into another comment

The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).

The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of your ros package for the ctags command (this assumes the current working dir of vim is your projects directory, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your project.

map <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
"This is to tag the include for ros packages the current project depends on
map <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<cr>
"map <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<cr>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion

Vim's present working dir (:pwd) needs to be the root directory of your package because calling "rospack cflags-only-I" without package name argument will use the current dir as package name. This is the case if you start vim in that directory or use :cd to change there. Alternatively you could somehow (I do not know how, though) find out the package name of the project your file belongs to, to give it to the rospack call.

The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).

The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of your the ros package in which you are editing files for the ctags command (this assumes the current working dir of vim is your projects directory, see below, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your current file's project.

In contrast to the solution of mjcarroll this creates a tagfile in your project's directory, which is specific to the dependencies of your project. Therefore you need to create the tags (F11) for each of the packages in which you are editing files. On the other hand vim should be faster looking up its tag database and also include non-ros dependencies.

map <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
"This is to tag the include for ros packages the current project depends on
map <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<cr>
"map <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<cr>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion

Vim's present working dir (:pwd) needs to be the root directory of your package (i.e., the output of rospack find <yourpackage>) because calling "rospack cflags-only-I" without package name argument will use the current dir as package name. This is the case if you start vim in that directory or use :cd to change there. Alternatively you could somehow (I do not know how, though) find out the package name of the project your file belongs to, to give it to the rospack call.

The following .vimrc snippet is mostly from here. Visit the link to see how to create stl, qt, sdl and qt4 tags (or deactivate the "set"-lines).

The only ros-specific part is `rospack cflags-only-I` in the third line, which lists all the include directories of the ros package in which you are editing files for the ctags command (this assumes the current working dir of vim is your projects directory, see below, which btw also allows you to use :mak). With this, hitting F11 will generate completion tags for your current file's project.

In contrast to the solution of mjcarroll this creates a tagfile in your project's directory, which is specific to the dependencies of your project. Therefore you need to create the tags (F11) for each of the packages in which you are editing files. On the other hand vim should be faster looking up its tag database and also include non-ros dependencies.database.

map <f12> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
"This is to tag the include for ros packages the current project depends on
map <f11> :!ctags -R --languages=c++ --c++-kinds=+p --fields=+iaS --extra=+q . `rospack cflags-only-I`<cr>
"map <f11> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ~/local/usr/include/<cr>
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/stdlibtags
set tags+=~/.vim/tags/gltags
"set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4tags
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
"let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,preview ",longest 
"END Omnicompletion

Vim's present working dir (:pwd) needs to be the root directory of your package (i.e., the output of rospack find <yourpackage>) because calling "rospack cflags-only-I" without package name argument will use the current dir as package name. This is the case if you start vim in that directory or use :cd to change there. Alternatively you could somehow (I do not know how, though) find out the package name of the project your file belongs to, to give it to the rospack call.