Vim Tutorial – Day 2

October 24, 2017

Vim Tutorial – Day 2

In my last Vim tutorial post, I covered 4 basic moves to help you navigate around in Vim.

Vim logo

In this post, I’m going to focus more on how you can use the :help command to help yourself get more familiar with Vim, as well as some more advanced commands.

Vim as martial arts

Like I mentioned in my Day 1 post about Vim, watching skilled Vim users is like watching skilled martial artists.

It’s amazing and yet also a little bit intimidating, especially if you’re new. When I started, there are things I wish I knew. So I’m continuing to write this tiny Vim tutorial to help you get started.

To get their advanced skills, martial artists often train through the use of exercises called katas.

So I’m calling these Vim exercises kata after those simple karate exercises designed to train the mind and muscle for specific applications.

One of my favorite sites for learning more advanced Vim moves is Vimgolf. The other resource I’ve used is a book called Practical Vim.

Day 2 – Help Yourself

In Day 2, we’re going to focus on how you can continue learning Vim especially when you run into commands you’re unsure about. To do that, you’re going to need to learn this first move.

Move 1 – Help

The :help command in Vim will let you browse the Vim help manual to learn about the various commands. The help command opens in a split window.

If you want a full window, type :h | only or :help | only

Kata Steps:
  • Open up Vim. You should be in normal mode by default.
  • Type :help (or :h). You’re typing “colon” followed by “help”.
  • If you want to see a full window, type :h | only.

Move 2 – Joining Lines

One cool move I learned was to join multiple lines. For example, let’s say I have 3 lines as follows (where a newline or blank line counts as a line):



If the cursor is position on the number 1 and I then type 3J, I get the following output:

1 2

You’ll notice all 3 lines have been “joined” on one line.

If I had typed 5J, nothing would have happened. Apparently, if I try to give a command to join more lines than actually exists, nothing will happen.

Kata Steps:
  • Start Vim in normal mode.
  • Figure out how many lines you want to join (or guess).
  • Then type the number followed by “J”. For example, type “2J” to join 2 lines together.

Move 3 – Repeat

Another cool move I learned was “repeat”, represented by the “.” (dot) operator. The dot operator repeats your last command in Vim.

As an example, let’s go back to the join command from Move 2.

Again, let’s say I have 3 lines as follows (where a newline or blank line counts as a line):



This time, with the cursor on the number 1, I type 2J and get the following output:


If I then type the dot operator ., then I get the following output:

1 2

You can even type a number followed by . to repeat the last command that number of times. For example 2. would repeat the last command twice.

Kata Steps:
  • Start Vim in normal mode.
  • Issue a command (such as J) in Vim.
  • To repeat the command again, type “.” or a number followed by “.” to repeat the last command a specific number of times.

Move 4 – Help on CTRL + Some Key

Often times, reading blog posts or Vimgolf, I would see a key combination notated as <C-R> or <C-A>.

But I had no idea how to ask Vim for help on the key combination. Those key combinations mean press “control” plus the noted key simultaneously.

It turns out, it’s pretty easy. You just type :help c_ctrl-R.

Kata Steps:
  • Boot up Vim in normal mode.
  • If you don’t know what a key combination like does, then you can type :help c_ctrl-R to figure out what pressing “CTRL” and that particular key does.


The above “katas” will get you started in Vim. Finally, you are ready to begin making Vim your personal text editor!

  • If you don’t have access to StackOverlow, Vim has a built in help manual via the :help command.
  • Join (“J”) and repeat (“.”) can save you some time when needing to join lines or repeat past commands.