How To — Vim Beginner Basics

Here are some vim tips that should get you up and running starting from zero knowledge of Vim. Why vim? I personally like it because it’s fast to spawn several vim instances within milliseconds, easy to customize your settings and save it to a single config file use on other computers or even servers, it’s highly extensible, and since most keystrokes are a shortcut; you can become very fast at editing text.

The goal of after reading this is to be able to know how to edit in vim at a slightly faster pace than traditional methods. Hopefully the lists and gifs will be a good reference to learn from, since I’d like to think a majority of people learn better with those than reading a block of text. Assuming familiarity of the terminal, we can open vim with typing in vim in the terminal. If you don’t have vim , then you can search up on how to install it easily with the OS that you currently have. For Windows users, I highly recommend using WSL so that you can use one of the Linux package managers.

Immediately, we see how to exit. Type :q to exit. Here are some common ways to exit:

Vim cool

Movement

Okay, so this might be a highly an controversial thing to say, but I think arrow keys are okay to use on a very small keyboard. My current keyboard is a 60%, and the arrow keys are only 2.5 keys away from hjkl. I also have macros on fn+arrow to do specific things because it is easier to do fn+arrow than fn+hjkl . Maybe back in the days of full keyboards, it would have been slow to use arrows over hjkl due to them being several keys apart. I think it’s fine due to the advancement of peripherals in today’s age though. Also, some people in the generation of gamers might feel more comfortable with having their hands more spread apart. With that out of the way, movement in vim can be done with hjkl or up down left right . There will be more movement shortcuts in the modes section below.

Quitting

Modes

Vim has modes you need to enter in order to do specific things. This is the very first concept you need to grasp before using Vim. For the most part, you will normally be in insert or normal mode. My gifs will have a plugin called vim-airline that shows which mode you are in with color codes.

Vim modes

Normal Mode

You can get into this mode by pressing esc , you will also start out in this mode when entering a file. Normal mode makes you not able to edit text directly, and makes your keyboard keys into shortcuts for movement and utility. Some common normal mode shortcuts:

Normal Mode Movement

Moving around quickly

Normal Mode Utility

Quick utility

Insert Mode

Hit i while in normal mode to get into insert mode. This mode lets you type in the file, and hit esc to return to normal mode. There are a few shortcuts you can use this in this mode, but I like to keep shortcuts to normal mode only as much as possible.

Insert mode

Visual Mode

This mode is like highlighting text on a browser or any highlightable text on an app. Start out in normal mode, and you can enter one of these 3 sub modes (move around with arrows or hjkl):

We can perform normal mode shortcuts once we highlight the text we want:

Now we can start to combine some shortcuts we learned in normal mode with visual mode:

Visual Mode
Visual Line Mode
Visual Block Mode

Tips

Normal mode shortcuts have a combination feature that is somewhat intuitive. So a will literally mean ‘a’, as in ‘delete a word’, which is actually a shortcut:

i in a combination stands for ‘in’, so here is ‘deleting in )’:

di” di)

The shortcut combos kind of have a pythonic psuedocode feel to it where you think it might work, and it actually does work when you try it. I think knowing these shortcut combos will greatly boost the speed of your editing, as it is a lot faster the type daw with one hand rather than move your mouse to the word, double click to highlight the word, and then press backspace to delete.

Don’t get discouraged if you are slow at first, that’s just life. The learning curve at first might be a little steep, but it plateaus pretty fast after you get used to it. It is true that the more you learn vim, the less you will know about it. However, thinking and gauging whether you should learn this new editing shortcut/method or not is what will make you competent in vim. In the end, everyone has their own preference on how they like to do things, which is arguably the most important factor when deciding on a text editor. More advanced vim topics might come at a later date.

Like my content? GithubTwitterMediumSupport Me

Software Engineer living in Tokyo | Linux | Cats | https://github.com/kai-dg | https://haruspace.dev | https://ko-fi.com/harukai