Execute Multiple Commands in Vim

September 08, 2016

Reading time ~1 minute

Today I needed to perform multiple transforms on a chunk of text in a file and found a nice solution in Vim! Initially I was thinking about VISUAL mode in Vim and chaining transforms the way I would do with sed (i.e. s/one/two/g;s/^/ /;s/$/,/). It turns out this doesn't exactly work in Vim, but it's not too far off the mark.

The following syntax works in Vim NORMAL mode:

:%s/^/  / | %s/string/replace/g | %s/$/,/

And in VISUAL mode, the sytax is slightly different. Select a bunch of lines to operate on, and then use the following:

:'<,'>s/^/  / | :'<,'>s/string/replace/g | :'<,'>s/$/,/

Protecting Git Branches

I've been thinking about the vulnerability of the primary Git branch for the last several weeks. Mostly out of paranoia about destroying ...… Continue reading

Exciting Dotfile Enhancements

Published on September 11, 2016

Signing Commits in Git

Published on September 05, 2016