Building your own Sublime out of free components with vim
Building your own Sublime out of free components with vim
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:
- vim pathogen to allow you to easily add and remove vim plugins. Somewhat like Sublime's package installer, only with many more packages available since vim has a 30+ year history.
- NERDtree gives you a separate directory tree to browse and open files from, like the left-hand side tree in Sublime.
- If you're a Rubyist, install vim-ruby:
git clone git://github.com/vim-ruby/vim-ruby.git ~/.vim/bundle/vim-ruby
- 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-256color
to 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.
Example .vimrc:
call pathogen#infect()
syntax on
filetype plugin indent on
:set number
colorscheme xoria256
Now you can start vim and 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!
This entry was posted in Technology and tagged english, technology by Ramón Cahenzli. Bookmark thepermalink. 
Building your own Sublime out of free components with vim
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:
- vim pathogen to allow you to easily add and remove vim plugins. Somewhat like Sublime's package installer, only with many more packages available since vim has a 30+ year history.
- NERDtree gives you a separate directory tree to browse and open files from, like the left-hand side tree in Sublime.
- If you're a Rubyist, install vim-ruby:
git clone git://github.com/vim-ruby/vim-ruby.git ~/.vim/bundle/vim-ruby
- 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 toscreen-256color
to 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.
Example .vimrc:
call pathogen#infect()
syntax on
filetype plugin indent on
:set number
colorscheme xoria256
Now you can start vim and 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!
2 THOUGHTS ON "BUILDING YOUR OWN SUBLIME OUT OF FREE COMPONENTS WITH VIM"
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 solarizedhttp://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.