1 hour
Here are links to lessons that should be completed before this lesson:
The goal of this topic is to provide a basic introduction to a powerful and ubiquitous text editor called Vim. With a foundation in using Vim, you will be able to edit text files (e.g. code, configuration files, etc.) on just about any UNIX- or Linux-based computer. (And you can use Vim on Windows machines, too, if they want!)
Some situations you might use Vim include:
Participants will be able to:
h
, j
, k
, l
i
w
, e
, b
, and their capital-letter equivalentsgg
) or end (G
) of the file<n>G
and :<n>
){
and }
)%
)*
and #
)f
and F
)/
and ?
, n
and N
)i
, I
, a
, A
, o
, O
)d
/dd
command)d3w
)u
) and redo (ctrl-R
):
)Vim is a program you can use on the command line (Terminal) to edit text files. When using the command line, sometimes you’ll need to use Vim to edit a file, so it’s good to know the basics of how to use Vim.
Vim does not have a official documentation. The interactive Vim tutorial is quite enough to cover all of the vim.
If you want to get good idea about vim many of the different commands you can use in less time , you can watch this video : How to Use Vim - Tutorial
To get started with Vim, try doing these things on the command line:
vim favorites.txt
i
. Typing i
puts you in “insert mode”, which lets you insert text into the file.i
, a
, and o
will put you back in insert mode!):w
and then press enter.:q
and pressing enter.vim favorites.txt
again. You can use i
to edit your file again, and escape to leave insert mode when you’re done.:wq
to save and then quit together.Now you’ve learned enough to handle 90% of Vim situations :-). But there are tons of additional Vim commands you can learn, including commands to move through the file, edit text, copy and paste, and much more.
Try using vimtutor
to learn more about Vim! vimtutor
is a Vim tutorial that comes on your computer. vimtutor
will actually open the tutorial file on your computer using Vim, and as you go through the tutorial you’ll use Vim commands to navigate and edit the file.
To get started:
vimtutor
. Read the text on the screen.j
is like a down arrow in Vim. Use the j
key to scroll down through the tutorial.Do the rest of vimtutor
to learn a lot more about Vim! There are 7 lessons total. Go through as much as you have time to do (we recommend spending about 1 hour total on this lesson).
See if you can do these things in Vim without looking at any reference material:
More advanced:
h
, j
, k
, and l
a bunch of times. Which commands did you use instead?