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:
- It’s hard for non-vimmers to help me. I’m no wizard, and as I learn basic programming skills I often need help. I should make that as easy as possible.
- Mentally being in ‘Vim mode’ for a single task and switching contexts for everything else is terrible. If I had a nickel for every time I’ve typed ‘jjjjj’ on some webform…
- As I alluded to above, standard shortcuts like
cmd-s
to save,ctrl-tab
to move between tabs, orcmd-c
to copy, needed to be created. Sure, these functions all exist, but the fact that Vim land is so completely different than every other part of using a computer detracts from the power it does offer. - Vim is lightweight, but it’s actually still a bit slow. Performance dips when it shouldn’t. E.g.
ctrlP
from my home directory causes a 10 second delay. Line indent guide lines and cursorline highlights slow it down as well. - I know it’s antithetical to using Vim, but sometimes I want visual mode to work like everywhere else:
shift-alt-right
from insert mode should trigger selection. - After learning them well enough, I’ve decided buffers are just stupid.
-
.swp
files. Fuck those things. - Everything is customizable, which is a blessing and a curse. Configuration OCD is real.
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 #
- [X] Select and edit text within delimiters easily.
- SU has built-in commands. Vintage works for this to. E.g.
vi'
selects all text within single quotes.
- SU has built-in commands. Vintage works for this to. E.g.
- [X] Big block cursor for Normal Mode (Using Vintage)
- Package: Block Cursor Everywhere
- [X] Surround sentences, words, selection, with tags or brackets, or change out surrounded punctuation.
- Native support is actually pretty solid for creating surrounds. Vintage surround + Sublime surround also seem to work alight here for swapping/deleting
- [X] Toggling between day and nightmode (changing color schemes) w/shortcut.
- Package: Solarized Toggle
- [X] Toggling spell check and issuing corrections w/o a mouse.
- Package: KeyboardSpellCheck
- [ ] MRU opening of files. (ctrlp.vim MRU)
- I want to open a fresh sublime session and easily open any of the last 5-10 files I’ve worked on using fuzzy match. No, not
cmd-shift-t
until I get lucky…
- I want to open a fresh sublime session and easily open any of the last 5-10 files I’ve worked on using fuzzy match. No, not
- [ ] GOOD markdown syntax highlighting. My Vim settings are kind of unbeatable, and I’m using markdown all the time. Ideally this means bold section headers, colorized backticks, syntax highlights for code blocks, colorized links for both the text and the actual URL.
- Right now MarkdownEditing package is decent, but the color scheme hijack sucks.
- [ ] Navigate project tree easily (like nerdtree), meaning moving up and down directory levels without a mouse.
- [ ] Splits navigation. Native support is not great so far.
- [ ] Add numbers that are in a line or column (equivalent to visSum.vim)
- [ ] Navigating Ruby on Rails projects magically. [tpopes
vim-rails
will be missed] - [ ] Macros and saved custom kb shortcuts! Some favorites:
- (I still need to explore sublimes macros.)
<leader>
here is '
, so a few key taps transforms entire documents
Commas to newlines
map <leader>ccc :%s/,/\r/g<CR>
Newlines to commas
map <leader>nnn :%s/\n/,/g<CR>
‘Escpaped’ new lines to actual newlines
map <leader>rrr :%s/\\n/\r/g<CR>
Kill trailing whitespace (Sublime does have a package for this)
map <leader>k :%s/\s\+$//e
Surround every line in document with single quotes
map <leader>" :%s/^\(.*\)$/'\1'/g<CR>
Destroy every instance of the last search pattern
map <leader>/ :%s/<C-R>///g<CR>
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
Remove every line containing last search
:g//d
Remove every line not containing last search
:v//d
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