How-To: Vim Functionality with Sublime Looks
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.
- vim-monokai -Vim colorscheme by Marcin Kulik
- .vimrc -Vim configuration file
- pip -Python package installer
- Powerline -Status bar plugin by Kim Silkebækken
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.
Adding Monokai Color Theme
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.
- Grab the vim-monokai theme from GitHub, available here.
- Inside the repo’s
/colorsfolder you should see
We will add monokai to our vim configuration in the Putting it All Together with .vimrc section.
Installing Powerline with pip
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
Putting it All Together with
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.
.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.
.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 format
colorscheme monokai-Use the Monokai theme we copied over earlier
set number-Show line number gutter on the left
set incsearch-[optional] Show matches while searching
set hlsearch-[optional] Search highlighting
- lines 8 through 10 get us up and running with Powerline in Vim
set laststatus=2-Keep our status bar visible and properly positioned
A Final Note on Fonts
If 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 myself.
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
Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!