Building your own Sublime out of free components with vim

I recently discovered Sublime Text and bought a license even though I rarely use proprietary software for work. That’s how good it felt to me.

But if you’re comfortable with an editor like vim, you can make vim feel almost like Sublime, using only free and open source software (FOSS). vim (and emacs) have had many of the features that Sublime has, in some cases for decades. Here’s a very small and simple guide for making vim look and behave a little like Sublime.

First, install the required components into your .vim directory:

  1. vim-plug instead of pathogen or Vundle to manage plugins automatically.
  2. NERDtree gives you a separate directory tree to browse and open files from, like the left-hand side tree in Sublime.
  3. A terribly nice 256 color color scheme (works in the terminal and in the vim GUI version): PaperColor. Make sure your terminal supports 256 colors, set your TERM variable to something like xterm-256color. If you use a terminal multiplexer like screen or tmux, set it to screen-256color to make sure your background colors work properly.
  4. To replicate the Control-P/Command-P (Go To File) behavior found in Sublime, use the ctrlp.vim plugin.
  5. Set up your vimrc to load most of this stuff. See below for the relevant section of mine.

Example .vimrc:

call plug#begin('~/.vim/plugged')

Plug 'scrooloose/nerdtree'
Plug 'kien/ctrlp.vim'
Plug 'NLKNguyen/papercolor-theme'

call plug#end()

syntax on
filetype plugin indent on
set number

colorscheme PaperColor
set background=dark

Restart vim and do a :PluginInstall.

After another restart of vim you can execute :NERDtree to get a nice tree on the left-hand side, then open a file and perhaps split your window (Ctrl-W n) and load each of the files in separate split frames. Navigate back and forth between frames using Ctrl-w Ctrl-w (or Ctrl-w followed by the arrow key of the direction you want to move in). You can also split each of the frames into tabs, just like in Sublime.

And to finish off, one of the features I use most frequently in Sublime is the “find inside files in a folder” search (Ctrl-Shift-F). In vim, you can accomplish the same using e.g. vimgrep. First, grep for something in the files you want: :vimgrep meta_datum **/*.rb. Then bring up the quicklist to see your results: :cw. This way, you can navigate almost in the same way as in Sublime.

Two screenshots of all this combined below. Now go on and customize vim to fit your needs exactly!

0 thoughts on “Building your own Sublime out of free components with vim”

  1. I wish this was possible, but not on Windows. The console VIM on Windows is so crippled and buggy I gave up…

    1. That’s pretty awesome! But you it would really, really benefit from GNU/Linux and Windows support. Otherwise it’s “just” a MacVim plugin, not a vim plugin 馃檨

      Could it run in the plain-jane console vim as well? The plugins I’ve referred to above all run even in console mode, so if I like, I can have all that stuff over SSH when tinkering around on my web server.

      1. Yes. But shortcuts on mac are only usable with MacVim. I’ll implement Linux support too in the future (like using only ctrl mappings instead of cmd).

    1. You’re right, I should mention Atom. I wrote this article over 3 years ago, when Atom didn’t exist 馃檪 Though Sublime clearly inspired Atom as well, so most of the stuff applies.

Leave a Reply

Your email address will not be published. Required fields are marked *