Efficient editor navigation for BEGINNERS in VIM - Part 1
Tags: ide, vim, code, vscode
Published: 2019-11-07 02:25:42

In this post, I'm going to teach you how to efficiently navigate in Vim editor instead of you spamming keys `j, k, l, h` (or the arrow keys) just to go to a certain character or line.

This post is for aspiring Vim ninjas that want to make Vim as their primary editor when coding, or even writing anything.

***I recommend not to read the whole post but instead follow the guide that I will leave on each paragraph, so you would have time to learn and build that muscle memory as we go learn each command in Vim.***

***I suggest to archive or save this so you can go back to this post anytime. The goal is to learn it step-by-step, and not learning all at once.***

Vim is great and powerful (if you have mastered all the keystrokes, shortcuts, mnemonics, etc), but it does take time to get used to it, especially building that muscle memory. It takes guts to fully grasp Vim and hone your skills with it.

Without further ado, let's start! 



But first, let's go back to basics. To navigate to each character:

`j` to go down, `k` to go up, `h` to get left, and `l` to go right. For beginners, this may seem awkward because we used to do it on arrow keys or `WASD` keys, in VIM, it's different.
> When Bill Joy created the vi text editor he used the ADM-3A terminal, which had the arrows on hjkl keys. Naturally he reused the same keys and the rest is history. 
>[https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys](https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys)

And for me, this is fine, so I can rest my fingers where I can reach the most common shortcut keys in Vim.

Now you know the basic navigation, let's take another level, will take it slowly, as we tackle each command that we will be using.

***Legend***
TTL - Time to Learn 😅

To start, copy this gist and save it somewhere you can easily find.
{% gist https://gist.github.com/benborla/6bca43e2a01afe2bfb3f8f3b14f480bb file=lorem.txt %}

Once done, open your terminal and run this command `vim path-to-lorem.txt`, this will bring up the `lorem.txt` that you just saved. We will be using this sample text file to practice.

In order to navigate easily, we have to enable the `Line Number`, most IDE has this built-in on their application, but in Vim, you have to enable this feature.

In your VIM make sure you are in Normal mode, type `:set number` and hit enter, as you can see this will show the line number(s) in your editor, most of Vim users I know use Relative Number as this is much easier to navigate line by line.

You can see more about relative number by typing `:h relativenumber`
>Show the line number relative to the line with the cursor in front of each line.

### Commands 

**Navigate through each word**
`w` jump to the start of the word this includes punctuation.
![w command](https://media.giphy.com/media/JszvSZJFtdEvXwHryA/giphy.gif)

`W` jump to the start of the word, does not include punctuations.
![W command](https://media.giphy.com/media/ViOf8MKKbKgfkZwWZA/giphy.gif)

`b` jump to the end of the word this includes punctuation.
![b command](https://media.giphy.com/media/Js1FK2eV37rvMMEowr/giphy.gif)

`B` jump to the end of the word, does not include punctuations.
![B command](https://media.giphy.com/media/f8ytZhFhVsD8WacZ73/giphy.gif)

** Jump to the start or the end of the line **
`0` jump to the start of the line
![0 command](https://media.giphy.com/media/KbAyk6OiIvqH60LKi5/giphy.gif)

`$` jump to the end of the line.
![$ command](https://media.giphy.com/media/TLCqqfgGdO5qkLobqK/giphy.gif)

*** TTL: 5 to 10 minutes ***

---


*End of Part 1*