Vim is a very popular text editor for Unix-like systems, written by Bram Moolenaar. I have been using Vim for a couple of years now and have found some nice features that make it more efficient for my use.
First of all one should look into the root configuration file /etc/vim/vimrc. I uncommented some things here that I found useful, like for instance `
1 2 3 4 5
For the rest of the changes i updatet .vimrc and the .vim folder in the home directory. In my ~/.vimrc I have some basic commands :
1 2 3 4 5 6 7 8
This changes things like the lenght of the indentation (which I found to be way too long with the default setup), as well as enabling plugins, setting the right clipboard etc.
This is where it gets interesting. There is alot of plugins out there and I’ve found some really nice ones. Pathogen is used to make dealing with plugins very easy. To make this work follow the instructions from the plugin page and remember to add the following to ~/.vimrc :
Exuberant Ctags is another great plugin that makes a tags database wich is used by vim to autocomplete variables and functions. Together with code_complete and omniCppComplete it also offers autocompletion of function parameters and class and struct members much the same way that can be found with IDE’s like eclipse:
If you’re running a debian systems the easiest way to install ctags is to use
sudo apt-get install exuberant-ctags
Code_complete can just be downloaded here and placed in the ~/.vim/plugin/ directory.
To use these plugins tag-files is made by generating tags based on source code files. Im using the following command to do this:
ctags -R * --c++-kinds=+p --fields=+iaS --extra=+q
When executing this command it will generate a file in the current directory and make tags based on all source code in the current and all subdirectories. The tag file is used by ctags, code_complete and omniCppComplete. To let vim know where to look for tag files on has to specify this in vimrc by
Ctags searches for tag-files which is specified in ~/.vimrc. I’m using the following in my .vimrc file to look for tag files
Lastly I use git hooks to update tag files in projects. The best way to do this is to first make the directory ~/.git_template where you can define templates for git to use every time you run git init. In the .git_templates directory I have a directory for git hooks with two files: _
1 2 3 4 5 6
With these scripts you will generate a new tag file in the local .git directory of the current project every time you make a commit.
For python source code I use the wonderful jedi-vim. Which is a really great and advanced plugin, providing the same functionality ctags and omniCppComplete provides for C/C++.
Install it with the following
1 2 3 4
I also found installing supertab useful
To configure jedi-vim and supertab, put the following in your .vimrc file
1 2 3 4