I recently wrote about Sublime Text, and what a nice text editor it is. It really is a very nice editor and I don’t want to rain on its parade. I bought a license even though I never use proprietary software for work, haven’t used any for over 10 years now. That’s how good I think Sublime is.
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:
- vundle instead of pathogen to manage plugins automatically.
- NERDtree gives you a separate directory tree to browse and open files from, like the left-hand side tree in Sublime.
- A terribly nice 256 color color scheme (works in the terminal and in the vim GUI version): xoria256. 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-256colorto make sure your background colors work properly.
- To replicate the Control-P/Command-P (Go To File) behavior found in Sublime, you can use vim’s Command-T plugin. Thanks for the hint, Stefan! Another similar plugin, written entirely in vimscript so it doesn’t need Ruby, is ctrlp.vim.
- Set up your vimrc to load most of this stuff. See below for mine.
set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'gmarik/Vundle.vim' Plugin 'scrooloose/nerdtree' Plugin 'kien/ctrlp.vim' call vundle#end() syntax on filetype plugin indent on :set number colorscheme xoria256
Restart vim and do a
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!