My Story

Fine, I'll admit it... I've done Sublime Text... but I never inhaled! At some point in my software engineering career I made the bold life-choice to abandon Sublime Text and move to the Vim side, and I've never looked back! Why did I make the switch? I'm not really sure myself, I was doing quite well (if I dont say so myself) with Sublime and had customized it to my liking. Perhaps it was an unconcious decision made after watching other people code or maybe I just wanted some of that sweet sweet OG hacker street cred (that I assumed came from using Vim or emacs). Regardless, I made the switch, I am confident I am more efficient, and I want to make it as painless as it can be for you to transition too. This is not a blog post about 'how to Vim,' just some tips and resources to get you over the hump sooner.

Switching editors is painful

I anticipated having a productivity slump during my transition to Vim, and it definitely happened. A lot of programmers are very vocal about the loss of productivity that happens when switching to Vim and spout some nonsense about just dealing with it or that there is nothing to be done! I'm here to tell you why and how to make that transition as smoothly as possible.

Tip 1

Vim isn't really that much different than Sublime at it's most basic level. There is an insert mode and a normal mode, one to type and one to move around (ignoring visual, select, command-line, and ex mode for now). Hell, you can even move around with the arrow keys if you want! STOP! JUST KIDDING! Don't use the arrow keys and really, really focus on using 'h', 'j', 'k', and 'l' to navigate around your file in normal mode. Why? One of the huge bonuses of Vim is to reduce reliance on your mouse and focus on keeping your hands on your homerow. Shifting your hand down and to the right 5-10 inches is a waste of time! Be lazy!

noremap  <Up> ""  
noremap! <Up> <Esc>  
noremap  <Down> ""  
noremap! <Down> <Esc>  
noremap  <Left> ""  
noremap! <Left> <Esc>  
noremap  <Right> ""  
noremap! <Right> <Esc>  

Tip 2

WTF you're using 'h', 'j', 'k', and 'l' to navigate? Cut that out! Hmm... that seems slightly hypocritical, but alas, once you are really comfortable with using the four keys to navigate one space at a time, get even more comfortable moving more than one space at a time! Really utilize Vim's movement shortcut keys like 'w', 'b', 'e', 'f', and 't'! These keys will allow you to fly around your file without holding down any of the single movement keys. Practice using these keys in combination with numbers to move around even faster.

Tip 3

Use the resources at your fingertips!

  • Vim Tutor
    • Jump into your console and spend a few minutes playing with vimtutor! Just type vimtutor into your terminal and you can play around with an interactive tutorial. It's easily accessible and will really jump start your Vimdom.
  • Vim Adventures
    • If you are feeling frisky enough to drop some cash, head on over to Vim Adventures and plug away at their game. It's a pretty novel and entertaining way to practice the basics.
  • YouTube
    • I highly recommend checking out Thoughtbot's YouTube channel, they post a lot of videos on Vim and have a lot of great tips on speeding up whether you're a beginner or an expert.

Bonus JavaScript Tip

I really, really disliked the repetition of doing carriage returns for JavaScript function signatures... so I stole someone's mapping and bound the carriage return to Ctrl + C since it's such a common occurence writing JS code.

imap <C-c> <CR><Esc>O  

Hitting Ctrl + C after typing the opening curly brace/parens or whatever will insert a carriage return or CR.

El Fin

Vim is not scary! It's awesome and will not even impede your productivity by that much if you treat it as a regular editor while you are learning. Give it a shot, there are tons of resources out there for beginner Vim users to help!

Tags

Javascript , vim , software engineering , IDE , editor

About the author
comments powered by Disqus