Development/Vim

Recommended Vim plug-ins
Use Pathogen or Vundle to install any of these mentioned plug-ins.

localvimrc
The localvimrc plug-in allows you to have a .lvimrc file to overwrite/extended your main ~/.vimrc file without cluttering it.

You should add an entry .lvimrc to your global .gitignore file to avoid listing the file when using git.

Fugitive interface with Git
A great plugin to use Git from within Vim is fugitive. It offers diff, blame, jumping around in the commit tree and more all on a few key strokes. Its self-description (A Git wrapper so awesome, it should be illegal) is a little bit exaggerated, but just a little ;-)

OmniCppComplete
If you install the Vim OmniCppComplete plugin you also get auto completion of function names and class members when using ctags as the tags file is built with the necessary OmniCpp options. The vim path variable is evaluated if OmniCpp_NamespaceSearch is set to 2 to determine in which files to look for namespaces, it may help to not have /usr/include in there.. See also above for the vim path variable setting.

ctags
ctags is the other local indexer tool supported by the build system. To use it in vim:


 * always run 'make tags' after a toplevel build completed
 * add this to your ~/.vimrc:


 * then you can use  or   in vim to jump to the definition or declaration of a classname,  jumps back
 * you can also use to search for the class or function or variable name at the cursor position and jump to the first hit.

See the vim help  for more details.

In case you notice problems ctags parsing C++11 code, give Universal Ctags a try.

YouCompleteMe
YouCompleteMe uses clangd to generate useful autocomplete information.

You can generate a clang compilation database file that can be used by YCM through make vim-ide-integration. For more details see

Vimagit
Emacs has magit, Vim has vimagit, basically a frontend to the git add --interactive or git add --patch (respectively git commit --interactive or git commit --patch) commands. Great stuff to create a commit of only portions of your edits from within your favorite editor. Available as vimagit from the vim online script repository, install as a pathogen.vim bundle. See the feature set on the vimagit GitHub page.

The vim path variable
Setting of the vim path variable influences quite some things, like where vim looks for files when hitting for GotoFile under cursor, or the OmniCppComplete plugin (see below) looks for namespaces. A possible set in your ~/.vimrc would be where the shell environment variable VIM_INC before the first invocation of vim can be set to for example where $(pwd) prints the current working tree directory.

Indentation of keywords and blocks
To properly align a break keyword with the corresponding case keyword, not indent public: and private: within a class declaration and not indent inside a namespace block (if you know what hitting or  does then you know why ;-) use these C-indent settings in your .vimrc or .lvimrc:

Build the current module using Ctrl+K
To build the current file's module when hitting place this snippet in your ~/.vimrc

Show the issue in a browser
Of course this function would need to be hacked if firefox isn't the browser to be used, and new prefixes can be added. To use this function, simply place the cursor on a bug reference in the code like and hit.

Show the current function name
To use this function, simply hit f: the line containing the function name will be displayed.

Remove trailing whitespace when saving
Put this into your  to remove all trailing whitespace when saving.

Editing zipped XML files
If you debug some import problem in a zipped XML format, put this to your :

And then you can open the file in vim directly, editing the relevant XML substream in-place.

Pretty-printing
Pretty-printing is really needed for XML files, as LO typically writes no whitespace around XML tags by default, so it's hard to read or write the XML for a human.

The easy way:

Then hitting will pretty-print the XML. There are two problems with this approach: it doesn't handle non-XML (for example RTF) files, and it also doesn't handle invalid XML.

A more complex solution to add to :

(prettyprint script, XML formatter, RTF formatter)

Jumping to a random line
Jumping to a random line is useful in testsuite files where a framework is local to a file, so adding a new test in a particular file is useful, but always appending new tests at the end would cause too much conflicts.

Vim Tips Wiki covers to to some extent, a Python script is also available. Here is a macro to use the later:

Then executing



will jump to a random line inside the file

Avoiding UUIDs in SmartArt files
in your vimrc, then put pptx-kill-uuid.py in PATH.

Finally open `ppt/diagrams/data1.xml`in a PPTX file in vim, press `,ls` and it makes all those UUIDs human-readable.

GNU ID-utils
As mentioned in GNU ID-utils, the eid command makes use of some environment variables when invoking the editor:

To be able to invoke the lid utility from within Vim we need a key mapping and function call, you may place this section into your .vimrc file:

lid.vim plugin
lid.vim is a plugin to integrate GNU ID-utils with Vim, providing a lid -g output in the quickfix window that can be travelled using the :cnext and :cprev commands respectively their keyboard mappings.