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:
- vim-plug instead of pathogen or Vundle 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): 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 toscreen-256color
to make sure your background colors work properly. - To replicate the Control-P/Command-P (Go To File) behavior found in Sublime, use the ctrlp.vim plugin.
- 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!
Sublime *is* the second best editor ever! The feature I like most about Sublime is the quickly-find-file-in-project-or-folder command “ctrl-p”. There’s the Command-T plugin for vim that does about the same: https://github.com/wincent/Command-T
and xoria256 is the second best colorscheme :), i prefer solarized http://ethanschoonover.com/solarized
https://github.com/altercation/solarized
beautiful theme for terminal and graphical vim.
An almost complete bunch of Vim-Plugins preconfigured:
https://github.com/akitaonrails/vimfiles
Works like a charm.
I wish this was possible, but not on Windows. The console VIM on Windows is so crippled and buggy I gave up…
What about graphical vim on Windows? Doesn’t it work there?
I’ve started a project that implements all these features builtin via custom plugins and hacks. If anyone is interested just have a look 馃檪
https://github.com/fatih/vim-awesome
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.
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).
What about Atom?
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.