In this video, we introduce the help features, Vimtutor and :help
We then take a look at why we use hjk and l to move around the screen and how to remember which one is up and which one is down.
It is then shown that you can type a number before hjk and l to move that in that direction that number of times - going to the top or the bottom of the file using a number larger than the number of lines in the file, then k to go to the top or j to go to the bottom.
We see how to turn line numbering on and off with :set nu and :set nonu
A quick way to get to the bottom of the file is G and to get to the top use gg
1% is another way to get to the top of the file and 100% will take you to the bottom and any integer in between will take you that percentage into the file.
r will replace a single character
~ will toggle upper/lower case
Everything shown in this video is in normal mode
We start with shortcuts to get the to end of the line ($) or the beginning of the line (0).
The "end" key also takes us to the end of the line and the "home" key also takes us to the beginning of the line.
We also see the cntl+Home takes us to the top of the file and cntl+end takes us to the bottom of the file.
We review how to quit out of vim with:
:q - quit when there are no changes to the file
:q! - when we want to quit and NOT save changes we've made
:wq - write (changes) and quit
And I show two 2 ways to write and quit:
:x - write (changes) and quit
ZZ - write (changes) and quit
Here i mention that I've been saying press the escape key then :x to quit, we don't need to press it every time, this just brings us to the "normal mode", and often we are already in normal mode, so pressing it is unneeded, it wont hurt anything, but it doesn't have to be pressed if we are already in normal mode.
Yank and Put - it is Vims version of "Cut and Paste" we see that:
yy - Yanks an entire line and puts it into memory.
P - puts the line we yanked above the line we are on
p - puts the line we yanked below the line we are on
u - undo the last change
dd - will delete an entire line (and place it in memory - like cut)
3Y - will yank (copy) 3 lines (any number will copy that number of lines - 3 is demonstrated)
:set relativenumber - will turn on relative line numbering making the line we are on 0 (showing where the line is relative to the rest of the lines in the file)
:set norelativenumber - will turn off relative line numbering
:set rnu - turn on relative number (shortcut)
:set nornu - turn off relative number (shortcut)
Things we look at in this video are:
2D - (from the beginning of the line) cuts text
P - paste the 2 lines deleted
2D - (from the middle of the line) Deletes from the cursor to the end of the line
P - Pastes the text deleted (cut)
2Y - Yanks (copies) the entire 2 lines starting from the line the cursor is on
2D - Delete (cuts) the text from where the cursor is at on that line and the entire next line.
u - undo
D - Deletes (cuts) text from the cursor to the end of the line
i - Puts us into insert mode
escape - puts us back into normal mode
C - Change text (from cursor to the end of the line (and go into insert mode)
A - Append - jump to the end of the line and go into insert mode
i - insert mode (starting before character you are on)
a - insert mode (starting after the character you are on) append after character
gg- go to top of file
dw - delete a word
d2w - delete 2 words
u - undo
dw - delete from cursor to the end of the word (and the space following that word)
w - go to the next word
2w - go over 2 words
b - go back 1 word
2b - go back 2 words
e - jump to the end of the word
2e - jump to the end of the 2nd word
ge - go to the end of the previous word
2g3 - go to the end of the word 2 words back
w - jump to the end of the word
W - jump to the end of the next word, after next whitespace characters (space, end of line)
b - jump to next word
B - jump back one word, before previous white-space character (space, end of line)
We look at the pattern vim uses for its commands and we find out it is [number] verb [number] .
We look at a few examples of how to do things with a single line command like 2d3l (delete 2 times 3 characters). The different examples are to demonstrate the pattern Vim uses for most commands.
We then see that > is for indent, but we can't just press the > key by itself. >> is indent the current line, >2j is indent the current line and the next 2 lines. And 2>2j does not follow the standard Vim pattern.
We can repeat the indent 2 times by pressing . after indent, and then we see that . will repeat any single line command, and that is why the single line command is so important to understand.