VIM Flashcards
Modes of operation of VIM:
1) command mode, default mode, keys causes action, not characters
2) insert mode, typing produces characters
3) lasline mode, search, quit, save, starts with the :
Explain: i esc o O a A w b B
i gets you in insert mode
escape goes back to the command mode
o gets you insert mode one line below the cursor
O gets you insert mode one line above the cursor
a allows typing after the current position of the cursor
A jumps to the end of the line and allows to append to the end
w moves the cursor forward one word, W skips spaces
b moves backward one word, B skips spaces
What does 30w and 30b do inside vim?
30w moves the cursor forward 30 lines
30b moves the cursor backward 30 lines
what do u and control r do?
Simply typing the u key, it undoes what you did last
u can be used repeatedly. it will take as separator the change between command and insert mode
control r gets gets you back what you undid with u
What do dd and typing p do?
dd deletes a whole line, puts it in a buffer, it is like ‘cutting’
typing p pastes what you dd’ed
What does 4dd do?
4dd deletes 4 lines down the cursor
What does x do the character where the cursor is?
x below a cursor “eats it”, that is, deletes it
What does control G do?
control g gives you all kinds of info about the file:
“new” [Modified][New file] 6 lines –33%– 6,0-1 All
new is the name of the file it has been modified has 6 lines cursor is at 33% of the length of the file character position/column marker
What does :shift zz do?
:shift zz gets you out, no changes are saved
What does / do while in command mode?
/ searches for a string, in command mode
How do you search for a string at the very beginning or the very end of a line?
/^ looks for the string at the very beginning of the line
/$ looks for the string at the very end of the line
What does this do?
:%s///
replaces one for the other but only the first occurrence per line, not all
What does this do?
:%s///g
replaces Globally all instances (all the matches)
What does this do?
:%s///gc
replaces Globally all instances but asks for confirmation
How do you select characters, lines and columns in visual mode?
v plus an arrow key in the desired direction selects words
V plus an arrow key in the desired direction selects whole lines
C v plus an arrow key in the desired direction selects columns of text