This post is the follow up of vim adventures I.
At this stage you should be able to move around inside a file, search for strings and insert text. You can probably even exit the damn thing without setting the house on fire.
Now you’d like to make Vim pretty, to make it your own. But before going down the rabbit hole of customisation, check out romainl’s list of best practices to get you started: idiomatic-vimrc.
A good font makes all the difference for code readability and general terminal aesthetics. I like Termsyn (ask me if you want the OSX version) because of its crisp appearance on LCD screens and its stocky letters that remain extremely readable in densely packed text. There are plenty of others which are also popular: Tamsyn (osx dfonts), Gohufont, Terminus, Inconsolata, Fira…
When it comes to plugins, there’s an overwhelming number available, so it’s best to ease yourself in with these popular ones to get started:
- The nicest plugin manager I came across: plug
- To display a fancy status bar thingy: lightline
- To make your code pretty: gruvbox
- To combine the two above: lightline-gruvbox
- To display your project’s hierarchy: dirvish
- To look for files (vim command-line-interface only): fzf
- To look for files (both in CLI and GUI): ctrlp
- To align stuff (like a group variables): lion
- To automaticaly rebuild your ctags (for easy navigation): gutentags. You need to install universal ctags or at least exubertant ctags on your system.
- To change the quotes and other surrounding pairs: surround
- To quickly comment out blocks of code: commentary
- To manage your code snipets: snipmate
- To git in vim: fugitive
Some day, you might ditch most of those plugins. But for now, take your time and allow the plugins to assist you in hiking the steep learning curve. Chances are, Vim will eventually become the only editor you’ll ever need.
Once you’ve customized vim, you may want to use the modal style of control for everything. In that case, there are two main approaches to choose from:
Approach I: Omnipotent VIM
You may even find some plugins for web browsing or mail reading but I think spacemacs is probably more appropriate as an OS-like experience.
Approach II: Omnipresent VIM
Alternatively, if you want to keep your vim small and pretty, you can ‘vimify’ the rest of your workflow:
- Most IDEs have plugins that emulate the basic VIM controls
- For browsing, firefox/chrome plugins allow you to surf the web with VIM controls (or use qutebrowser)
- mutt is a great mail client that can work very well with vim (I’ll post an article about this)
- tig is a great keyboard-only git interface
Although I was happy to try out vim-like controls for my IDE, web browsing and zsh, I ultimately found that using the native shortcuts for each application is more pleasant and a good mental exercise.
A few more tips for the road
- If after a week or two you still can’t break the habit of using the arrows to move around in a file, you can try disabling them by pasting the below code into your vimrc. I’ve removed this since but it worked for me at the time.
noremap <Up> <NOP> noremap <Down> <NOP> noremap <Left> <NOP> noremap <Right> <NOP>
Ctrl+[instead of Escape (closer to home row)
Ctrl+hinstead of Backspace
Ctrl+win insert mode to delete the last word
Ctrl+iinstead of Tab
- Save your little finger, remap caps lock to control (in osx go to settings/keyboard/modifier keys)
- Remember to use
f(move to char in line) and
/(search pattern) to move around
- Start reading Practical Vim by Drew Neil
This post is part II of the Vim Adventures series, here is part III.
If you want to comment feel free to shout me a good oul Tweet @PierreAclement…