Vi(m) Editor Flashcards

1
Q

The three vi editor modes

A

command mode, insert mode, and ex mode

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

In command mode, this is how you move the cursor one character to the right.

A

l (lowercase L)

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

In command mode, this is how you move the cursor one character to the left.

A

h

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

In command mode, this is how you move the cursor down one line.

A

j (lowercase)

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

In command mode, this is how you move the cursor up one line.

A

k (lowercase)

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

It means to yank in the vi editor

A

“Copy (yank) a line”

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

In command mode, this is how you copy an entire line that the cursor is currently on.

A

yy

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

In command mode, this is how you copy the current line that the cursor is on, as well as the line beneath the current line (2 lines total).

A

2yy

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

In command mode, this is how you copy the current line and a certain amount of additional lines.

A

yy, where # includes the current line and however many other lines wished to be copied.

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

In command mode, this is how you paste the contents from a yank/copy, pasting it on the line after your cursor.

A

p (lowercase)

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

In command mode, this is how you paste the contents from a yank/copy, pasting it on the line before your cursor.

A

P (uppercase)

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

In command mode, this is how you move the cursor to a specific line #.

A

G or #gg

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

In command mode, this is how you move the cursor to the beginning of the last line in the file.

A

G

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

In command mode, this is how you move the cursor to the first line on the terminal screen.

A

1G

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

In command mode, this is how you move the cursor to the last line on the terminal screen.

A

L

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

In command mode, this is how you move the cursor to the first line on the terminal screen.

A

H

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

In command mode, this is how you start insert mode and create a new line below the current cursor position, using one command.

A

o (lowercase O)

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

In command mode, this is how you undo movement or yanks or any command entered in command mode.

A

u (lowercase u)

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

In command mode, this is how you remove the current word the cursor is at and start insert mode, changing that text.

A

cc (lowercase)

20
Q

In command mode, this is how you search the file for a forward occurrence of what you are searching for.

A

/termhere

21
Q

In command mode, this is how you move to the next (forward/backward) occurrence of a searched term in the direction being searched.

A

n

22
Q

In command mode, this is how you search backwards, before the current cursor location.

A

?termhere

23
Q

In command mode, this is how you search backwards, before the current cursor location.

A

?termhere

24
Q

This is how you start insert mode to begin adding new text.

A

i, in command mode

25
Q

This is how you start insert mode with it set to overwrite old text.

A

R, in command mode

26
Q

This is how you start insert mode by removing the word the cursor is at and then being able to add new text.

A

cw, in command mode

27
Q

This is how you start insert mode to erase a line of text and then be able to insert new text.

A

cc, in command mode

28
Q

This is how you start ex mode.

A

”:” while in command mode

29
Q

This is how you replace the first occurrence of a word with another word.

A

:%s/example/new (from command mode)

30
Q

This is how you replace all occurrences of a word with another word.

A

:%s/example/new/g, where g stands for global (from command mode)

31
Q

This is how you save changes without exiting?

A

:w (from command mode)

32
Q

This is how you save changes and quit the vi editor (two possible ways).

A

:wq or ZZ (both from command mode)

33
Q

This is how you quit without saving changes.

A

:q (from command mode)

34
Q

This is how you load a new file to edit in vi editor. For it to work, you have to save your current file first.

A

:e /file.txt (from command mode)

35
Q

This is how you bring contents of an old file into a new one.

A

:r (from command mode)

36
Q

This is how you run shell commands from within the vi editor, example using the “ls /etc” command.

A

:!ls /etc (from command mode)

37
Q

This is how you get to command mode from insert mode.

A

ESC

38
Q

In command mode, this is how you delete a word.

A

dw

39
Q

In command mode, this is how you delete the character the cursor is on.

A

X (uppercase)

40
Q

In command mode, this is how you delete the entire current line and a certain amount of lines below the current line as well.

A

dd

41
Q

In command mode, this is how you delete the entire current line.

A

dd

42
Q

In command mode, this is how you delete more than one word from the current cursor.

A

dw

43
Q

In command mode, this is how you move the cursor to the beginning of the current line.

A

0 (zero)

44
Q

In command mode, this is how you refresh the document to the original state that you started editing it in without any changes made.

A

:e! (from command mode)

45
Q

In command mode, this is how you make line numbers visible.

A

:set nu (from command mode)

46
Q

In command mode, this is how you remove line numbers from being visible.

A

:set nonu (from command mode)

47
Q

In command mode, this is how you start insert mode where the new text starts AFTER the current cursor position.

A

a