Just because you’re using a command line editor does not mean you should have to do a time warp back to the days of green screen CRTs. This guide will walk through the process of setting up Vim to achieve a more Sublime-like experience. The target audience for this is a non-Vim user that finds him or herself having to hop into a CLI editor from time to time, and is looking for something a bit more familiar aesthetically.
“Will this make me even faster at Vim?” you may ask. Well, most likely not.
However, by giving yourself a consistent experience, going between editors will be less disorienting, allowing you to find your place within the same file quickly. Thus, going from your local GUI editor and then jumping into Vim for some quick server-side edits over SSH should be more seamless. As for the whole H,J,K,L home row navigation thing, you’re still on your own on that one.
Let’s see what we’ll be working with.
This is my rc file. There are many like it, but this one is mine. Without me, my rc file is useless. Without my rc file, I am useless.
The default syntax theme used by Sublime is Monokai. This theme is not included with Vim. Luckily, we can get pretty close using vim-monokai.
/colors
folder you should see monokai.vim
monokai.vim
to ~/.vim/colors/
We will add monokai to our vim configuration in the Putting it All Together with .vimrc section.
pip is a command line package manager used for installing Python packages. This is similar to npm in the Node world, or gem in Ruby.
We are going to use pip to install the Powerline status bar. This will display what mode we are in (normal, insert, visual, etc.), the Git branch we are working off of, encoding, language, and other useful things.
To install it, open your terminal of choice, and enter the below command.
pip install --user powerline-status
.vimrc
A dotfile ending in rc designates a configuration file. Other examples of rc files would be .bashrc
for Bash, .zshrc
for Zsh, .psqlrc
for Postgre and so on.
Your .vimrc
should be located in your home directory.
As dotfiles are hidden, you will not be able to browse to it using Finder. Instead, you will need to open the file through a terminal by typing either vim ~/.vimrc
or nano ~/.vimrc
. To open it with Sublime Text you can use subl ~/.vimrc
if you have the subl
alias set up for it.
Update your .vimrc
so it looks like the one below, lines 5 and 6 are optional.
An overview on what we’re doing here:
syntax on
-Enable syntax highlighting based on the file formatcolorscheme monokai
-Use the Monokai theme we copied over earlierset number
-Show line number gutter on the leftset incsearch
-[optional] Show matches while searchingset hlsearch
-[optional] Search highlightingset laststatus=2
-Keep our status bar visible and properly positionedIf you are finding that the Powerline status bar isn’t lining up properly, you may need to install one of the Powerline-specific patched fonts, available here. I’m fond of [Meslo LG M Regular for Powerline.ttf](https://github.com/powerline/fonts/blob/master/Meslo%20Slashed/Meslo%20LG%20M%20Regular%20for%20Powerline.ttf)
myself.
Change Font found under Profiles -> [ default profile] ->Text for iTerm2
Once the font is installed, you will need to update your terminal’s default font under the preference menu.
Questions/Comments/Other? Drop me a line via LinkedIn or GitHub