Vim tips that will change your life
Vim is objectively the best code editor there is. [Editor's note: Opinions are those of the author. Honeybadger remains neutral in the vim/emacs/sublime holy war]
No matter how much you know about Vim, there's still more to learn. Here are a few features it took me far too long to discover, that I will now aggresively sell to you.
Vim users! Are you tired of reaching all the way up to the
ESC key to leave insert mode?! THERE'S GOT TO BE A BETTER WAY! Starting now, you can use
Ctrl+C to exit insert mode anytime you want! But wait! There's more! Using
Ctrl+C requires no extra configuration! It comes out of the box with Vim!
Are you a two-keystroke slave? Kill two birds with one stone and save yourself THOUSANDS of nanoseconds over the course of your life by using
:x instead of
:wq when saving and quitting! That's right,
:x is the exact equivalent of
:wq. Put that in your pipe and smoke it (not literally).
Are you still installing plugins the old-fashioned way? With Vundle, you can install any Vim plugin in just seconds by adding a simple configuration directive! Want to try vim-rails? No problem. Does FuzzyFinder look interesting to you? Throw it on the pile! With Vundle, the world is your oyster!
Jumping among blank lines
k to move among lines can feel at times like jogging through waist-deep water. Why not take the express lane? Pressing
} will allow you to move upward and downward, respectively, from blank line to blank line.
Cleaning up improperly indented code
Let's face it, your co-workers are idiots. The success of your employer rests squarely on your shoulders and you don't have all day to spend fixing the poorly structured code written by the protohumans with whom you're forced to collaborate. Using the magic wand of
= in Vim, you can select any block of text (
Shift+V then up/down), hit the
= key, and presto! Your code will be beautifully indented before you can say "passive aggression"!