If you’ve been following my previous posts, I introduced why you’d want to use Vim and discussed the different modes available in Vim.

With that intro discussion out of the way, I want to show you how to start moving around in Normal mode! Over the next couple of posts, I’ll discuss the super basics and then progress up to more complex movements available to you.

To kick things off, let’s start with the most basic movements in Vim — moving Left, Down, Up, and Right one character at a time:

Moving One Character at a time

h (move left by a single character) j (move down by a single character) k (move up by a single character) l (move right by a single character)

Go ahead and load up a text file in Vim and try navigating around using these commands — remember to make sure you’re in Normal mode. For some of you (and this included myself), these movements are kind of unconventional and unfortunately, it’s just something you have to commit to muscle memory. The way I remember which direction each key corresponds to is:

The h key is the left most of the 4 keys, so it moves you left. The l key is the right most of the 4 keys so it moves you right. The j key has a bump at the bottom of most keyboards, so it moves you down. And then the k key is the only one left, so it goes up.

Some of you might be thinking — “Ughh, these keys are annoying! Let me just go back to using the arrow keys when I want to move around.” And yes, you could do that but then you’d be missing out on Vim’s efficiency because you’d most likely have to look back at your keyboard and fumble around each time you wanted to make a basic left, right, up or down movement. I highly encourage you to force yourself to commit these keys to muscle memory, and to help you along the way, we’re going to disable the arrow keys when using Vim :)

Brief segue about your .vimrc file

A couple of posts back, I mentioned how Vim is super powerful because it allows you to use its built-in shortcuts as well as customize and create new ones. How Vim does this is that it loads in a normal text file labeled “.vimrc” which contains all the settings you’ll want Vim to use. It’s in this file that you can add custom keyboard mappings and we’re going to do that now. We’re going to add 4 custom keyboard mappings that will disable the left, right, up and down arrow keys when you’re using Vim.

Steps

The first step is to locate your .vimrc file. For those of you using a Mac, it should be located in your home directory. Within your terminal session, enter the following:

cd ~

ls -a

At this point, you should see that a .vimrc file exists in this directory. If you don’t see one, that’s ok too — just proceed to the next step.

The second step is create or edit the .vimrc file by entering the following in your terminal session:

vim .vimrc

If you have an existing .vimrc file, you might see some text in there already. Either way, feel free to go to the end of the file and type the following:

noremap <up> <nop>

noremap <down> <nop>

noremap <left> <nop>

noremap <right> <nop>

Here’s how my .vimrc file looks like and you’ll see that I have those 4 lines in there as well! Don’t worry if your .vimrc file looks different from mine!

Once you’ve added these 4 lines into your .vimrc file, save and exit out of the file, and re-open your terminal session. Start editing any file using Vim, and in normal mode, try moving around with your arrow keys. Tada! They’re disabled :)

That’s all for this post — in my next post, I’ll go over some more complex movements such as how to move around by words!