In this blog post, I’ll share some tips that helped speed up my VIM learning trajectory.

My number 1 rule:

Something in your VIM workflow that sounds inefficient? too long? \(\implies\)Then yes, you’re right, and there is a trick within VIM that solves it quickly and efficiently. Google it, trust me.

My favorite hacks:

Content:

Switch your <ESC> and <CAPS> keys

Disable your arrow keys:

If you are serious about learning VIM, then please disable your arrow keys.

P.S: “If you’re really about that life”

You should only use<H-J-K-L> for local changes/movements, and use VIM advanced motions for big jumps. I personally don’t think I’m there yet.

Let the cursor move to your search pattern while typing:

Search in VIM is usually handled by / and ?, one drawback is that you have type the pattern you’re looking for then press <ENTER> to move to your target. incsearch let you move to your target while typing. Add the following to your .vimrc:

Faster navigation between splits inside VIM:

In your .vimrc add the following:

Move between local visual lines:

VIM splits a long line into multiple “visual” lines, yet, <h,j,k,l>, still jumps the whole line. If you want move vertically through the virtual lines, the you can use gi and gk. I personally have the keys j and k remaped indefinetely as follows:

Embrace the power of Registers 0, 1:

If you just started using VIM, then you might face this situation every damn day:

  1. You yank the word w1
  2. You move to another word w2
  3. You delete w2
  4. Click on p (in your mind, you wish to paste the word w1)
  5. VIM yanks the word w2 instead.
  6. You should normally start swearing at VIM.

The hack is to start embracing the world of REGISTERS. It’s okay if you don’t want to use them for general purposes (MACROS), but you should know that Register 0 is your friend. It holds the last yanked thing. Which you can quickly access using "0p.

Ditch w,b,e for W, B and E

Most of the time, I find myself wanting to use a motion or action on a “Big-Word”. Which you can access using W (resp. E, and B) instead of w (resp. e, and b). What I refered to as a “Big-Word” is the concatenation of any non-empty/ non-whitespace characters.

Quickly source your .vimrc (or .bashrc) from VIM

Type the following: :so%

Quickly save and quit VIM

VIM has a quick way to save and quit, you simply type shift+ZZ. But I’m not sure if there is something built-in to just save a file in normal mode without quitting (~ :w). Good news though, you can do so by mapping shift+ZS to :w. You can achieve so by adding the following line to your .vimrc:

TO-DO: