Search code examples
vimctagsvim-macros

Vim and Ctags tips and tricks


I have just installed Ctags (to help with C++ development) with my Vim (or rather gVim), and would like to find out your favorite commands, macros, shortcuts, tips that go along with it...

Share your best arsenal. What other Vim add-ons you would recommend for C++ on Vim development?

EDIT What other add-on you would use in conjunction with Ctags?

EDIT2 What version of gVim you use with tags? Does it make a difference?

EDIT3 How do you enhance your programming experience for both big and small projects?


Solution

  • Ctrl+] - go to definition
    Ctrl+T - Jump back from the definition.
    Ctrl+W Ctrl+] - Open the definition in a horizontal split

    Add these lines in vimrc
    map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
    map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>

    Ctrl+\ - Open the definition in a new tab
    Alt+] - Open the definition in a vertical split

    After the tags are generated. You can use the following keys to tag into and tag out of functions:

    Ctrl+Left MouseClick - Go to definition
    Ctrl+Right MouseClick - Jump back from definition