Vim Study Lab

In Mastering Vim in Vim, a vimtutor-inspired method of learning Vim is discussed:

The file, when sourced, turns the vim buffer into the vim study lab. The file consists of two parts. The first part is a hunk of vimscript that is executed when you source the file. It creates keyboard commands that make it easy to move the cards in the queues.

The second part is the queues themselves, Study, and Known. (The idea is that once you know something so well that you don't need to study it anymore, you can move it into the Known queue, just to keep it around for posterity.) The queues simply consist of a command and some information about it.

Read More →

A New Motion: Vim Skip

Motions are a fundamental unit of Vim's vocabulary, so it's sometimes surprising to see new ones appear in the form of plugins. Vim Skip (GitHub: jayflo / vim-skip), which was announced on reddit, allows you to skip the cursor to the centre of the line by pressing s. If you press it again you'll move half way from the current position to the end of the line, and so on, in a way that might remind you of Zeno's arrow paradox.

Before you get distracted contemplating the fabric of reality, take a moment to question why this might be useful: sometimes it's easier to think in terms of positions on a line than to skip between characters with f and t.

Read More →

Script Roundup: vim-airline-todo, vimcaps


vim-airline-todo (License: MIT) is an extension for vim-airline that shows a count in the status bar for your current to-do list.

The count is based on the number of files in a directory. Each task is a file, so it's a minimalist approach to managing to-do lists. The task list directory can be changed, as can the TODO text.


vimcaps (GitHub: suxpert / vimcaps, License: GPL) allows you to remap the caps lock key, in case you don't want to turn it off system-wide. It includes a C program for toggling the behaviour of the key, so the author is looking for help porting it to Mac OS X because he doesn't have a Mac.

Read More →

Words to Avoid in Tech Writing: Vim Plugin

Words to avoid

Wynn Netherland amended his vimrc to highlight words to avoid in tech writing. The snippet looks like this:

" Highlight words to avoid in tech writing
" =======================================
" obviously, basically, simply, of course, clearly,
" just, everyone knows, However, So, easy


highlight TechWordsToAvoid ctermbg=red ctermfg=white

function MatchTechWordsToAvoid()
  match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/

autocmd FileType markdown call MatchTechWordsToAvoid()
autocmd BufWinEnter *.md call MatchTechWordsToAvoid()
autocmd InsertEnter *.md call MatchTechWordsToAvoid()
autocmd InsertLeave *.md call MatchTechWordsToAvoid()
autocmd BufWinLeave *.md call clearmatches()

The MatchTechWordsToAvoid function is called whenever a Markdown file is opened. The match command takes a regular expression and matches the unwanted phrases that we can't help writing. The first argument to match can be used with highlight, so you can apply different highlights to different matches. In this case the background colour is set to red, so the unwanted words clearly stand out.

Read More →

Why Does Vim Need Threads?

There's a fork of Vim that supports threads (Hacker News discussion, Google Groups post), written by Thiago Arruda. Thiago's approach is to have a thread that captures user input events using a queue, which can then be processed when the main thread is free.

Sometimes Vim appears to lock up: I notice this when I launch The Silver Searcher. It's clear that an external process is being launched, so I just wait until it's done. A multithreaded approach could theoretically get around this: plugins and external programs could be launched while Vim continues to accept user input.

If you read through the vim_dev discussion it quickly becomes clear that this is not a trivial problem. However, the fork has generated a lot of enthusiasm from the community, so it'll be interesting to see where this goes.

Read More →

Script Roundup: ag.vim, WakaTime


Someone known as "sw dev" replied to the Usevim Feedburner email with ag.vim, a fork of ack.vim which has been adapted to work with The Silver Searcher.

It's possible to continue to use ack.vim with ag installed, but ag.vim supports the features ag has that ack doesn't. If you look at the ag.vim documentation, you'll see the extended options that it supports.


WakaTime is a time tracking service that has Vim support (GitHub: wakatime / vim-wakatime). Once you've installed it time will be tracked automatically -- the current project is derived from Git. You can also sign in at WakaTime to configure how projects are recognised.

Read More →

Minimalist Vim Workflow for Scala

Scala in Vim

In general, Java developers seem to like their IDEs. I don't think I've ever heard anyone openly profess their love for Eclipse, but it definitely has a lot of tools that make working with Java less painful.

As a consequence, it seems like many Scala developers use the same IDEs. This seems a little unnatural to me, because Scala feels lighter and somehow more Vim-friendly. In Coding Scala with Vim, Derek Wyatt talks about his Scala workflow, which you may find appealing if you're fed up with your IDE.

Read More →

Script Roundup: calendar.vim, Vizardry


calendar.vim (GitHub: itchyny / calendar.vim, License: MIT) by itchyny is a calendar for Vim that supports various views (day, week, month, year), and can even get events from Google Calendar and Google Task. The only dependency is curl (or wget) for accessing the web APIs.

The calendars can be displayed in split views by using the -split option -- for example: :Calendar -view=year -split=vertical -width=27. It even has Vim-friendly keys.


Vizardry (GitHub: ardagnir / vizardry, License: AGPL v3) is potentially the most user friendly Vim plugin manager. Why? Well, it supports GitHub for searching and installing plugins without even having to resort to using a browser. Just type :Invoke with a keyword.

Read More →

Vertically Centring the Cursor Line

I was reading Zen room for Vim: Focusing only on the essential, a post about a fork of VimRoom. There's been a glut of these distraction-free-writing plugins recently, but I like looking at their source because they all struggle to solve one simple problem: how to horizontally offset the cursor. In WriteRoom and similar applications, the text is heavily offset from the left of the screen because you're writing in fixed character length columns. You can't easily do that in Vim, so most plugins offset text by using vertical split windows with a hidden bar.

Another interesting thing I noticed these plugins doing is setting scrolloff to a high value. This setting means "scroll offset" -- the number of screen lines to keep above and below the cursor. If the cursor moves within a threshold then the content will be scrolled. Vim's documentation notes that setting it a very large value, like 999, causes the cursor line to be centred.

If you try out some desktop applications like WriteRoom you'll notice they do this as well. Rather than having to mess around with split windows you can just use a handy setting that has a desirable side effect.

Read More →