Vim for NaNoWriMo

November is National Novel Writing Month! On the NaNoWriMo forum, NewMexicoKid started a thread about using Vim for writing:

Starting a new thread on Vim because just today I discovered some power plugins and tools that I hadn't been aware of before; and that makes me think that there must be other Vim users out there who have still other Vim-related tips and tricks to share.

He's also created a summary of the tips from that thread: Vim for Writers.

Read More →

Script Roundup: Sneak, ctrlp-cmdpalette


It's always interesting to see a new motion. Sneak (GitHub: justinmk / vim-sneak, License: MIT) by Justin M. Keyes is a motion for moving "medium" distances -- that is, between f and /. It searches for matches across multiple lines, works with operators, and also supports repeats and visual mode.

It has some default mappings: s waits for two characters, then moves to the next match. Pressing ; will repeat the last s.

It's a bit like a cross between Seek and EasyMotion -- the author includes references to these plugins and the differences between them in Sneak's documentation.

Read More →

To fg or not to fg...

There's limitless variation for a Vim and shell-based workflow. I like to stay in Vim most of the time, switching to other windows for command-line tools with tmux. In my office I've noticed a seasoned Vim veteran using Vim and then backgrounding it to run shell commands. He'll switch back when he needs Vim.

This style has its advantages -- you could use shells inside Vim, but that's perhaps only useful if you want to get results into Vim easily. Also, pressing CTRL-Z to suspend Vim requires less key presses than the CTRL-A n or CTRL-A hjkl I press for navigating between tmux windows and panels.

Typing fg in most shells will bring a backgrounded process to the foreground. If you're running Vim and press CTRL-Z, you're actually causing the SIGSTOP signal to be sent to the process. The fg command is built into your shell, so each shell has its own quirks.

Read More →

The Silver Searcher

I'm a search don't sort kind of guy, so when I was trying to make sense of gigabytes of XML files I instinctively reached for ack. Unfortunately ack struggled with this unholy corpus of legacy drivel. Overhearing my dismay a coworker asked "why aren't you using Silver Searcher?"

It turns out that The Silver Search made light work the XML files, so I looked at how to plug it into Vim. The command-line parameters are compatible with Ack, so all I had to do was change the ackprg:

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

If you want to use the same plugin as me, it's mileszs / ack.vim.

Read More →

Script Roundup: united-front

United Front

united-front (GitHub: ardagnir / united-front, License: AGPL v3) by James Kolb is a plugin for syncing registers between instances of Vim. First a server is run with vim --servername name, and then you can connect other clients to it.

I had a look at the source to see how it works. Whenever one of the events FocusLost, CursorHold, or VimEnter is triggered, a function called SendVimInfo is run. This function calls remote_expr which causes UnitedFront_ReadFrontFile to run on the other instances.

The UnitedFront_ReadFrontFile function reads .unitedfront for registers. That file is written by WriteFrontFile which packs the desired registers based on an array called savedRegs.

Read More →

Presentations with Vim and git-slides

Sometimes when you're creating a technical talk, using PowerPoint or Keynote feels extremely awkward. Adding syntax highlighted code samples requires an extra step, and dipping into live coding isn't elegant.

Many speakers prefer to present using Vim -- each slide can be a file, tab, or whatever makes sense based on the content.

A new take on this idea is git-slides by Samuel GĂ©lineau. It uses a Git commit for each slide, and a Vim plugin for authoring and presenting the slides. Once it's installed sl displays the next slide, and sh shows the previous one. ss saves a slide, and sb inserts a new one.

Read More →

Zsh's vi Mode

If you find Zsh's shortcuts awkward, then you might be pleased to know it can be switched into vi mode. It supports vi line editing mode which can be enabled with bindkey -v.

Shells that use Readline can be set to use vi mode by setting the following in ~/.inputrc:

set editing-mode vi
set blink-matching-paren on

Zsh doesn't use Readline, however, so it will check if you want to use vi or Emacs shortcuts based on the $EDITOR variable. You can override the setting with bindkey -v for vi or bindkey -e for Emacs.

Read More →

Script Roundup: Accordion, VerticalHelp


Accordion (GitHub: mattboehm / vim-accordion, License: Vim) is a Vim window manager that automatically shrinks vertical split windows so you can focus on the active window. It's by the same author as Unstack and can be used with Unstack to show stack traces in vertically split windows.


VerticalHelp by Mel Davis is a plugin that makes help open in vertical splits. This may work better for you if you use a widescreen monitor. It functions just like the standard help command, :help, and can be run by typing :H.

Read More →

Global Git Ignore

For years I dumped this into my .gitignore files: *.sw?. Then I realised that some people don't use Vim, and therefore probably don't want to see my editor-specific .gitignore entries. Different editors handle swap and recovery files different ways, so it seems redundant to force these settings on everyone.

A better approach is to use a global option. Run git config --global core.excludesfile ~/.gitignore. Then you can add *.sw?, and perhaps *~ as well. I like to add .DS_Store because Windows developers don't need to worry about that nonsense, and they should probably add Thumbs.db.

Read More →

Emmet: HTML Expansion and Traversal

One of the things I love about Vim is it has some efficient tag editing features: I use cit (change inner tag) all the time when editing HTML or XML. However, there's always room for improvement. Emmet is a project that brings workflow improvements to editors for working with HTML and CSS. It can expand CSS selectors to the equivalent HTML. CSS selectors are an efficient shorthand for those of us who write a lot of CSS and client-side JavaScript.

Emmet can also wrap lines in new tags, expand self-closing tags to a pair, insert snippets, and more. All of the features are documented with videos at

Emmet-vim by Yasuhiro Matsumoto brings some of these features to Vim. For example, html:5 then C-y will expand into a basic HTML5 document. This also works for CSS-style expansions. If you've got ImageMagick installed then it can even add width and height attributes to img tags.

Read More →