More Expressions

When I previously wrote about Counting and Calculating with Vim I mentioned the use of the expression register for inserting the results of calculations: when in Insert mode, press CTRL-R = then type an expression. Expressions can do a lot more than simple mathematical calculations -- this article outlines a few interesting things you can do with them.

Interrogating and Experimenting

When experimenting with expressions, you sometimes just want to see the output before doing anything with the results. One easy way to explore registers is to use :echo to print the results first. When in Normal mode, type the following:


This will print the environmental variable, $VIMRUNTIME. To perform a simple calculation, use the same command:

Read More →

Script Roundup: MiniBufExpl, vim-github-comment

MiniBufExpl Updates

Techlive Zheng sent in an update for MiniBufExpl (GitHub: techlivezheng / vim-plugin-minibufexpl. This is an old plugin that has passed between several authors, but continues to be popular thanks to Zheng's updates. The most recent release is 6.5.0, which includes a lot of bug fixes and improvements.

If you haven't seen it before, MiniBufExpl adds a small bar that displays each buffer and allows buffers to be navigated. The list looks like tabs, so it essentially makes Vim behave more like a typical GUI editor where buffers and tabs are equivalent.


vim-github-comment (GitHub: mmozuras / vim-github-comment, License: MIT) by Mindaugas MozĊĞras allows you to post a GitHub comment about the last line that was committed. It does this by using the command-line git binary and curl to access GitHub's API.

Read More →

Beginner's Guide to Beginner's Guides

Earlier this week I wrote Beginner's Guide to Unite, which was an attempt to demystify the popular Unite plugin. I noticed people grumbling on Reddit that it didn't contain any installation instructions.

I've written a little bit about working with plugin managers before:

The Windows-specific post came out of a series of articles on Windows and Vim. So, what are plugin managers, why are they needed, and how are plugins installed?

Read More →

Script Roundup: vim-origami, vim-c-cr

Send in your Vim scripts for review through our contact form.


Origami (GitHub: kshenoy / vim-origami, License: _MIT/X11) by Kartik Shenoy is a plugin for working with folds. It can align foldmarkers, insert start and end foldmarkers, and more.

The default mappings are all prefixed with <Leader>. For example, <Leader>zax aligns all folds at level x, and <Leader>ze deletes the current foldmarker.


vim-c-cr (GitHub: jtmkrueger / vim-c-cr) by John Krueger remaps CTRL-Enter and CTRL-C to add new behaviour for working with brackets. Positioning the cursor over {, [, or ( and hitting CTRL-Enter will cause Vim to insert two new lines, with the corresponding closing bracket on the second line.

Read More →

Counting and Calculating with Vim

I was working with a particularly unfriendly SQL dump file which was raising errors indicating that my data had the wrong amount of columns. To figure out what was going on, I used Vim to count the number of columns and then corrected the data using a substitution command.

To count the number of columns, I used %s/,//gn. The n flag causes :substitute to return the number of matches without actually performing any changes. The data itself had columns separated by commas, so all I needed to search for was a single comma. For more on flags, see :help :s_flags.

Counting with Vim

Read More →

Vim and Elixir


My mental landscape is dotted with the decaying husks of half-learned programming languages. The latest of these is Elixir, a functional programming language built on Erlang VM:

It is a dynamic language with flexible syntax with macros support that leverages Erlang's abilities to build concurrent, distributed, fault-tolerant applications with hot code upgrades.

Read More →

Script Roundup: shootingstar, thumbnail.vim

Send in your Vim scripts for review through our contact form.


Shootingstar (GitHub: jceb / vim-shootingstar, License: Vim) by Jan Christoph Ebersbach is based in the star command which automatically searches forward in Normal mode for the word under the cursor. Rather than searching for the word, the plugin searches for the text fragment that begins at the cursor's location.

This is implemented using getline() and match() -- getline() gets the current line, which is fed through match() with col('.') which gets the byte index of the cursor. It's a compact plugin, so you can check out the source to see how it all works.



Read More →

Moving Windows

As Vim users, we like to work with split windows. We tend to split them ad hoc rather than according to a fixed scheme -- I'll often use a vertical split for code | unit test, but it's so easy to split windows that I'll open more as needed, quite arbitrarily.

Armed with just :split (shortcut: CTRL-W_s, alias: :sp) and :vsplit (shortcut: CTRL-W_v, alias: :vs), it's possible to get by productively without taking advantage of the hidden wealth of window management commands that lie just beneath the surface. Let's look at one category of these commands: moving windows.

Flippin' Windows

Vim's documentation for window movement is under :help window-moving. The first command it introduces is CTRL-W r, which rotates windows downwards and rightwards. This is useful, but what I usually want to do is switch between a horizontal and vertical layout.

Read More →