Vi Editor Flashcards

1
Q

Which is your preferred editor?

A

vi editor, universal editor.

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

What are the different modes of the vi/vim editor?

A

Escape, Insert and Command mode.
visual mode.

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

How to quit Vim without saving any changes?

A

:q

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

How can you quit Vim while saving the changes you made?

A

:wq, :x, :wq!, shift zz

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

Let’s say the word “NYC” appears in a file hundred times, and you want to replace it with
“NJ” everywhere. What command would you use while you are inside a Vim editor?

A

: to enter
command mode then %s/NYC/NJ/g, it replace NYC with NJ everywhere in the file (g for global).

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

While editing a file using vi editor and you want to change a name "Robert" to "bobby",
how would you do that?

A

press ce or cw while in escape mode, make sure the cursor is on Robert, then type bobby

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

How would you select a range of lines, copy and paste them at the end of the file?

A

while in
escape mode, place your cursor on the first line you want to copy and press v to go into visual mode.

Then use the arrow keys to select the lines you want to copy and press y then press shift g to go to
the end of the file and p to paste the lines

esc, v then select range of line, y, esc, go to line where to paste, p

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

How would you jump from the beginning of the line to the end of a line?

A

press shift 4
(stays in escape mode) or shift a (goes into insert mode)

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

How can you jump back from the end of a line to the beginning of the line?

A

press 0 or shift
6 (stays in escape mode)

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

How would you go to the last line of the file in vi or vim editor?

A

press shift g

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

How would you go back to first line of the file in vi or vim editor?

A

press gg

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

How to shift to insert mode in Vi editor?

A

press i

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

Why do we use "!" in addition to ":w" or ":wq" to quit?

A

to save and quit forcefully

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