Getting to Black Belt in Vim – Part 2 – Yellow Belt

Now that you’ve mastered the basics at white belt level, let’s get a bit faster. At yellow belt level, we’ll introduce motions and more editing commands. Let’s get started.

Yellow Belt

A motion is a movement of the cursor, either horizontally or vertically.

Horizontal motions:

  • w to move by word, b to move backwards by word.
  • 0 to move cursor to the start of the line, ^ to move to start of first character on line and $ to move to the end of the line.

Vertical motions:

  • H to move to the top of the screen, M to move cursor to middle of screen, L to move cursor to bottom of screen.
  • ( to move backwards by a sentence, ) to move forwards by a sentence.
  • { to move the cursor up by a paragraph, } to move down by a paragraph.

Edit operators:

  • yy to copy a whole line.
  • p to paste below cursor, P to paste above cursor.
  • dd to delete a whole line and put into clipboard (cut).

Repeating

You can add a number at the start of a motion or operator to repeat. For example:

  • 5w moves the cursor 5 words across, 3b moves the cursor 3 words back.
  • 3k moves the cursor 3 lines up.
  • 10dd deletes 10 lines.

The . (period) command repeats the last change we’ve made.

In the next part, we’ll learn to get faster still!

Published
Categorized as Vim Tagged