vi Commands Flashcards

1
Q

What are the commands for switching between insert and command mode?

A

i for going into insert

esc for going back to command mode

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

What does the following command do: x

A

Deletes the current character

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

What does the following command do: dd

A

Deletes the current line

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

What does the following command do: u

A

Undo the last change

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

What does the following command do: /

A

Searches for the text to follow

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

What does the following command do: :w

A

Writes to the file

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

What does the following command do: :wq

A

Writes to the file and quits

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

What does the following command do: :q

A

Quits if no change has been made

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

What does the following command do: :q!

A

Exit without saving

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

What does the following command do for cursor movement: h

A

One character left

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

What does the following command do for cursor movement: j

A

Move one line down

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

What does the following command do for cursor movement: k

A

Move one line up

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

What does the following command do for cursor movement: l

A

move one character right

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

What does the following command do for cursor movement: w

A

Move to the next word

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

What does the following command do for cursor movement: e

A

Move to the end of the current word

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

What does the following command do for cursor movement: b

A

Move to the beginning of the previous word

17
Q

What does the following command do for cursor movement: 0

A

Move to the beginning of the current line

18
Q

What does the following command do for cursor movement: $

A

Move to the end of the current line

19
Q

What does the following command do for screen movement: H

A

Move to the top of the screen

20
Q

What does the following command do for screen movement: L

A

Move to the bottom of the screen

21
Q

What does the following command do: ?

A

Searches backwards for something

22
Q

What does the following command do: o and O

A

Open a new line below or (above) the current line

23
Q

What does the following command do: i and I

A

Insert text before the current character or (at the beginning of the line)

24
Q

What does the following command do: a and (A)

A

Appends text at the end of the current character or (at the end of a line)

25
Q

What does the following command do: .

A

Redo the last modification command

26
Q

What does the following command do: yy or Y

A

Copy the current line

27
Q

What does the following command do: p

A

Paste

28
Q

What is the syntax for searching and replacing in vi?

A

:(%)s/wordToFind/replacementWord/(g)(c)

% = in all lines
g = find every occurrence
c = ask for confirmation first
29
Q

What happens when the % sign is removed in the following line?

:(%)s/wordToFind/replacementWord/(g)(c)

A

The search and replace only occurs in the CURRENT line, but still finds and replaces every occurrence in the current line