A Bitter Divorce: Moving from Vim to Sublime

Vim and I are…slowly…splitting up.

Update: as of July 2016, we got back together. For now…

Note: This is a post about one of the nerdiest topics imaginable. If you want to hear one man’s ‘there and back again’ about a text editor, read on. Otherwise, you can (and should) skip this post. The next one is probably about music :)

Background #

This all started around mid-2014 when I made the decision to learn Vim. At the time I was spending a fair amount of my day on servers where it made sense to be using an editor native to that [linux] environment. I didn’t want to be copying & pasting into different editors or scp-ing files to my local environment just to do basic text manipulation, (e.g. searching and sorting TCP traffic dumps using various regex patterns). Note: I’ve learned that it’s actually possible to connect your favorite editor to remote files over an SSH tunnel. Well darn…

I was also drawn to the idea of doing more with less. Vim comes out-of-the-box almost everywhere and requires little from your system to run. Why use more than one editor when you can use one for everything? So I started learning to do my editing, text manipulation, etc. in Vim.

It was painful at first.

As an example: When I started, I was using a version that wasn’t compiled with the clipboard, meaning cmd+c and cmd+v weren’t supported. Ouch…

Even later when I did have it, learning to effectively use the various registers (of which the system clipboard you know is but one) was a significant hurdle. I eventually just made my own mapping to mimic standard copy/paste. (More on this later).

But as I learned to record macros or create functions that I could recycle, rather than repeatedly constructing the same search patterns over and over again, it all started to look more promising. Mastering motions (e.g. ci) to replace text bounded by parentheses) and using the . key for repeating complicated edits, was actually kind of…fun. Not needing to move my hand to a mouse, even for creating new files and navigating projects (or really anything)? Well that’s the bees knees right there.

I could keep any custom configurations (my ~/.vimrc) stored server-side and committed to version control. My setup was completely portable, taking seconds to pull down onto a new environment.

Looking back, Vim was also the first ‘technology’ I learned with little guidance from peers. It was all google searches and Stack Overflow (and later, Vimcasts*). Some of the configuration was fairly technical to me, especially given my background. As an example, understanding and implementing a good status line isn’t trivial.

So now, many Stack Overflow posts and Vimcasts later, I’m pretty decent. Better than decent.

But using Vim still has problems. Enough that I think it’s time to change.

*Vimcasts are strangely satisfying. I recommend them even if you don’t use the editor…Maybe it’s the accent?

What’s actually wrong with it? #

Some of the main issues:

That said, moving off isn’t easy either. My Vim setup is hard-earned and very comfortable. Aside from that sunk cost, the movement patterns and other habits that come with modal editing are now deeply engrained in my fingers. As I make the awkward transition, I’m finding there are some things that I really don’t think I can go without. During this switch, I’m attempting to take the following abilities and features with me:

The list #

<leader> here is ', so a few key taps transforms entire documents

  1. Commas to newlines
    map <leader>ccc :%s/,/\r/g<CR>

  2. Newlines to commas
    map <leader>nnn :%s/\n/,/g<CR>

  3. ‘Escpaped’ new lines to actual newlines
    map <leader>rrr :%s/\\n/\r/g<CR>

  4. Kill trailing whitespace (Sublime does have a package for this)
    map <leader>k :%s/\s\+$//e

  5. Surround every line in document with single quotes
    map <leader>" :%s/^\(.*\)$/'\1'/g<CR>

  6. Destroy every instance of the last search pattern
    map <leader>/ :%s/<C-R>///g<CR>

  7. Save a series of find & replaces to a register for quick formatting output
    :%s/], /\r/g^M:%s/"//g^M:%s/,/ /g^M:%s/\ INC\| LLC//g

  8. Remove every line containing last search

  9. Remove every line not containing last search

So there it is. We’re at the start of a new, geeky journey. I’m excited.
If you have any recommendations here, let me know!

Back to Archive


Now read this

Wisdom Walks

A reflection on past wisdom, present discernment, and future value. And a little bit of ‘old man yells at cloud’ The other day I was out walking with my brother. It was a bright bluebird morning in his Denver suburb, and as we wandered... Continue →