Updates in Vim Land 2013

More than a year has passed since I wrote about updates of my Vim configuration. During that year, several changes accumulated concerning package management, folds, mappings and general organization of my .vimrc.

Vundle becomes NeoBundle

Vundle worked very well over the last year, but sometimes you want to pin a particular revision or branch of a repository. For instance, I keep a fork of the vim-markdown-folding plugin to prevent the plugin from setting the foldtext variable. With Shougo’s NeoBundle.vim plugin, I can simply specify my forked branch without messing with master. To switch from Vundle to NeoBundle add

if has('vim_starting')
    set rtp+=~/.vim/bundle/neobundle.vim
endif

call neobundle#rc(expand('~/.vim/bundle/'))

on top and replace Bundle with NeoBundle

...
NeoBundle 'matze/vim-markdown-folding', 'user-defined-foldtext'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'nanotech/jellybeans.vim'
...

There is one shortcoming compared to Vundle though: you won’t see a nice status and summary page when running :NeoBundleUpdate ☹.

Powerline becomes Airline

The author of the original vim-powerline plugin deprecated it in favor of Python-based powerline that covers much more than just Vim. Unfortunately, the old plugin isn’t maintained any more1 and the new one is a big project with currently 192 open issues and 25 open pull requests.

Fortunately, Bailey Ling stepped up and wrote a complete replacement called vim-airline that is lighter than powerline and written in pure Vimscript. I’ll spare you a screenshot as the look itself didn’t really change.

ag is better than ack is better than grep

Years ago I switched from regular grep to ack for typical searches because it is faster, has saner defaults and doesn’t search files and directories I am usually not interested in2. Recently, ag aka The Silver Searcher by Geoff Greer made the rounds. It is much faster than ack but provides an ack-compatible interface, hence with ack.vim and

let g:ackprg="ag --nogroup --nocolor --column"

you have ag at your finger tips.

Because ack was not extremely fast, I didn’t use it that often and never felt bothered calling it via :Ack and search for the current word with <C-r><C-w> from the command line. Now, it bothers me because launching the search should not be slower than the actual search. Hence I mapped the :Ack command with

nnoremap <C-i> :Ack! <C-r><C-w><CR>

Now, it’s a breeze to search for terms.

Folding

I’ve written about how I embraced folding already. I mark all important dot files with fold markers and try to use them in all source files wherever I can. For that purpose, I use a fork of vim-markdown-folding and my own vim-ini-fold and vim-tex-fold plugins. One big productivity boost comes from mapping <CR> to za which opens and closes a fold.

By default, the fold text (the compressed representation of the folded text) does not look very appealing. But it can be changed pretty easily with a custom fold text function like this.

One word about configuration management

Maintaining the old shell script for linking dot files and setting up Git submodules was working but not in the true spirit of “Don’ Repeat Yourself” because I had to edit it for each new dot file that I included.

Luckily, I stumbled upon seashell that takes care of such things through a sole Makefile. By default, make will initialize Git submodules found in the dotfile repository and make install will create symbolic links for any file or directory starting with a dot except for Git-specific files. Also, any files that ends with .export will be linked to without the .export suffix. Hence, you can have .gitconfig ignoring files in your dotfile repository and .gitconfig.export ignoring files in all Git repositories.

An additional Makefile.conf provides hooks to customize the initialization and export steps. This comes in handy for programs that store their configuration files in $XDG_CONFIG_DIR, e.g. ~/.config. Instead of versioning the entire ~/.config dir, you can use

EXPORT_CONTENT += .config

to link everything inside $DOT_DIR/.config to ~/.config. Another nice feature of seashell is post-installation code, that can be defined in the configuration. For example, msmtp requires that its configuration file can only be accessed by the user, hence adding

define install_append
@chmod 600 $(HOME)/.msmtprc
endef

ensures that this is the case.

1

The last commits were authored more than a year and committed ten months ago. 2: For example, ack ignores .git directories and backup~.