It is imperative that you have at least a beginner understanding of how to use vim
in order to be able to do your job confidently and effectively. Here’s a 10 minute crash course.
This document was last updated on 20 MARCH 2022
Vim is short for “visual modified.” Vim is a bare bones but extremely powerful text editor that you run in your terminal. You can (and will!) use it to make quick changes to files without having to open them in a separate application.
In your terminal, type the command vim ‹file name›
.
(Remember that when you see ‹this syntax›
, it's a sign to replace everything including the angle brackets with something specific to you. For example, if you want to open a file called configuration
you would type vim configuration
)
This is one of the most upvoted questions ever asked on StackOverflow. To close vim:
esc
key:
w
for writeq
for quitenter
for the command to take effectI speak this out loud as “escape colon write quit” — esc :wq
The most basic way to edit a file in vim is to type i
to enter INSERT
mode. Now you can type in the file. If that’s as far as you get in this tutorial for now, that’s fine.
To exit INSERT
mode, hit esc
Vim commands can only be typed when you are not in INSERT
mode. If you are in INSERT
mode, vim will tell you this by putting the word INSERT
at the bottom of the screen. To exit INSERT
mode, hit esc
Here are some commands I use all the time:
0
- moves you to the beginning of the line that the cursor is on$
- moves you to the end of the line that the cursor is ondd
- deletes the entire line that the cursor is ondw
- deletes the word that the cursor is onp
- pastes whatever you just deleted using the dd or dw commandu
- to undo your last commandHonestly, that’s enough for now. Everything else you can just do by using the arrow keys to move around. When you eventually get frustrated by that because it’s too slow, find five new commands you want to learn and memorize them.
touch practice
to make an empty file called practice)vim practice
)i
first to enter INSERT
mode!)esc
to exit INSERT
mode0
for beginning! $
for end!)dd
)p
)dw
)u
):w
):wq
)I just truly do not care. The arrow keys are right there and you probably already have good muscle memory about using them. Insiting that there are "right" and "wrong" ways to accomplish simple tasks is gatekeeping. The goal of gatekeepers is to make beginners feel like they don't belong. We ignore gatekeepers. If you like using hjkl
, use hjkl
. If you like using the arrow keys, use the arrow keys.
Linux.com has a nice 101 post on more basic vim
commands.
You are smart. You can do this. You have the right and the ability to learn anything you want to learn.