ctags
Install
$ sudo apt-get install exuberant-ctags
Usage
$ cd $PROJECT_HOME
$ ctags -R *
$ vi MyApp.cpp
Some frequently used shortcuts:
-
Go to definition: Ctrl-]
-
Jump back from definition: Ctrl-t
-
C-w C-]: Open the definition in a horizontal split
-
C-o/i: jump between items in jump list;
-
gf: "go to file", open the file under the cursor;
-
gd: "go to definition", go to the definition of a variable;
Ref: http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks
Buffer explorer
Install
-
Download bufexplorer-7.4.2.zip from it's website;
-
unzip it to ~/.vim/bundle/ (you have to install pathogen before hand);
-
restart vim;
Usage
:h buffer-explorer
I defined my
Tagbar
This plugin is for C/C++ code outline.
Installation: Downlaod majutsushi-tagbar-v2.6.1-0-ge872e67.zip from it's website, unzip to ~/.vim/bundle/ and restart vim.
:h tagbar
:TagbarToogle to open outline window; try
c.vim
Download cvim.zip v6.1.1 from its website. Unzip it to ~/.vim/bundle.
Add the following line to ~/.vimrc to override the default
let g:C_MapLeader = ','
Use ",rc" to save and compile. Use :cn
, :cp
, :cfirst
, :clast
, :cc
, :cclose
, :copen
to traverse in quickfix list (see :h quickfix
for full list of hotkeys).
Use F9 or ",rr" to run source file.
Use "2. Usage without GUI" and " 3. Hotkeys" in :h csupport
for full list of hotkeys.
Configuration for REPL
-
Add ":nnoremap
: make %:r && ./%:r " to ~/.vimrc; -
Open vim, copy the following c++ codes into it:
using namespace std;
int main() { cout << "hello C++.\n"; }
-
Save the file, syntastic(search tag syntastic for installation and usage details) will report an error: ‘cout’ was not declared in this scope
-
Add "#include
" at the beginning of the file, save it, and press , you can see the result;