VIM Flashcards

1
Q

Modes of operation of VIM:

A

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 :

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain: i esc o O a A w b B

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does 30w and 30b do inside vim?

A

30w moves the cursor forward 30 lines

30b moves the cursor backward 30 lines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what do u and control r do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do dd and typing p do?

A

dd deletes a whole line, puts it in a buffer, it is like ‘cutting’
typing p pastes what you dd’ed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does 4dd do?

A

4dd deletes 4 lines down the cursor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does x do the character where the cursor is?

A

x below a cursor “eats it”, that is, deletes it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does control G do?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does :shift zz do?

A

:shift zz gets you out, no changes are saved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does / do while in command mode?

A

/ searches for a string, in command mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you search for a string at the very beginning or the very end of a line?

A

/^ looks for the string at the very beginning of the line

/$ looks for the string at the very end of the line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does this do?

:%s///

A

replaces one for the other but only the first occurrence per line, not all

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does this do?

:%s///g

A

replaces Globally all instances (all the matches)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does this do?

:%s///gc

A

replaces Globally all instances but asks for confirmation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you select characters, lines and columns in visual mode?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does # vimdiff file1 file2 do?

A

compares files highlighting the differences

17
Q

What is the tutor for teaching you to use vim?

A

vimtutor

18
Q

How do you split vim vertically?

A

:vsplit

19
Q

How do you split vim horizontally?

A

:split