From Sublime to VIM

Tomas Romero
4 min readMay 31, 2015

--

Background

I’d been using Sublime for about 2 years. Having transitioned from Eclipse once I switched Java for Ruby, I remember how awesome it was: instant boot, lightweight UI, blazing fast searches and way better looking UI. All of Eclipse’s slowness was gone (I’ve heard it works much better with SSDs, but we didn’t had those on 2012 in Argentina).

Then I switched to a job were this guy coded on VIM. He actually used the gVim GUI client. We used to discuss which editor was better, on a pretty fanboy-ish style, without taking it too seriously.

The argument my teammate used the most against Sublime was that it wasn’t free software. Despite being an important issue, it wasn’t enough for me to change. I try it a few times, getting tired of it in like 5 minutes. I saw it too complicated (and I wasn’t completely wrong).

GUI vs Terminal

My rage against GUIs had started some time before. It was fundamentally a rage against using the mouse, against moving my hands too much. In a related move, I also switched to using a ThinkPad keyboard. I haven’t used a traditional mouse since. There were some episodes which boosted my sympathy for the shell:

  • Zsh: mighty auto-completion, history based auto-suggestions, autojump and command syntax highlighting.
  • Tmux: finally I could have Terminator panes inside my Guake terminal. I would discover session over SSH power some time later.

I though: “how awesome it would be to code directly in the shell”. And so it would be.

Getting fundamental Sublime features to VIM

I switched to a new project were I initially had some task-free time, so I decided it was finally the time to seriously try VIM. I felt I was missing some fundamental tools at the beggining.

Searching

Besides the initial difficulties from the modal nature of VIM, the first thing I missed most from sublime was the searching capabilities. There just didn’t existed a built in feature to match Sublime’s ctrl-p, ctrl-r, ctrl-shift-f and incremental search using ctrl-f. Also, I couldn’t navigate clearly through my files inside VIM. Ohh, and that little thing called Go To Definition. So I searched for plugins:

  • CtrlP: one of the most used VIM plugins, it provides file searching capabilities, just like ctrl-p did for Sublime. It also provides an easy way to switch from path based search to purely filename based search. You can even use jl to select available options!
  • CtrlP-Funky: replacement for ctrl-r, extending CtrlP.
  • CtrlSF: ctrl-shift-f replacement. Also you can navigate results with jk.
  • Some vimrc tweaking: incssearch, hlsearch and smartcase configuration on vimrc.
  • Vim-indexed-search: Shows total number of matches, and on which are you currently on.
  • NerdTree: Better file navigation for VIM. It lets you create, delete and move files/directories from within VIM. You can even use a command to open the current file on the tree. Also one of the most used VIM plugins.
  • Ctags: Allows go to definition on VIM. It isn’t a classic VIM plugin, you have to install it like a Unix package (apt-get for Debian). You have to manually mantain a TAGS file, but it’s almost instant and you can bind a shortcut to regenerate the file when there are changes on the project.

Manipulating Text

I used a lot ctrl-d on Sublime. It was one of itsmost powerfull features in my opinion. Also I used to move lines up and down with a few keystrokes, and commenting out blocks of text with a shortcut. We I got those on VIM:

  • Vim-multiple-cursors: ctrl-d for VIM. It has some huge improvements in relation to Sublime’s version: case sensitive matching and skip/go-to-previous match.
  • Vim-move: alt-arrows replacement for VIM. Move blocks of text line by line with a few keystrokes.
  • Tcomment: toggle comment on selected block of text (or current line) with gc.

Auto-completion

YouAutoCompleteMe: Allows auto-complete in a Sublime auto-complete fashion. It has some advantages over Sublime’s equivalent: use words from all files in the buffer (instead of just the current file) and you still see the list of results will tabbing between them.

Markdown editing

While not a built-in feature of sublime, I used to edit and preview markdown files quite often. I could edit md files with some decent approach to WYSIWYG inside sublime, and could run a command for rendering the file on a browser.

  • Vim-flavored-markdown: while not as good as its Sublime counterpart, it provides some basic level of md syntax highlight.
  • Vim-instant-markdown: much better that what I used for Sublime, as I could get instant updates on the browser render while I edit the md file.

GIT

I didn’t actually used Git plugins for Sublime. I just didn’t felt comfortable with them. As I know many people who do, I’ll list VIM counterparts:

  • Vim-fugitive: basically git blame/diff capabilities inside of VIM.
  • GitV: awesome CLI replacement for gitk. It also provides a way to track changes to particular sections of code within a file.
  • Vim-gitgutter: Shows if a line was added/deleted/changed compared to HEAD.

Copy/Paste

Copy-pasting between VIM and external programs is harder than expected for an editor, as VIM uses a different clipboard by default. To fix this, I had to set clipboard=unnamedplus and use GVIM (still from the terminal).

With that, I could get all Sublime features I used (some with important improvements) in VIM. All inside the shell! I then started adding all sorts of different plugins/shortcuts which made VIM amazing for me.

I still use Sublime for one particular task: editing big XML files. For some reason, VIM has a hard time parsing big XML files (as so does GEDIT), but with Sublime I have no problems.

And that’s a bit of the story of how and why I changed from Sublime Text to VIM.

--

--