Pt. 2 Ch. 12 A Gentle Introduction to vi Flashcards

1
Q

What’s the second most import thing to learn about vi?

A

It is a modal editor

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

When vi starts, it begins in what mode

A

Command mode

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

How do you exit vi?

A

:q

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

How do you enter insert mode in vi?

A

i

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

How do you exit insert mode and return to command mode in vi?

A

Esc

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

How do we save the change we just made to our file in vi?

A

an ex command such as :

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

How do we write our modified file in vi?

A

follow the colon with a w and then press enter

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

How can you undo the last change that you made in vi in command mode?

A

u

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

How do we append a text in vi?

A

a

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

How are the two ways we can insert a text by “opening a line”?

A

o the line below the current line

O the line above the current line

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

In vi what command deletes the current character?

A

x

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

in vi what deletes the current character and the next two characters?

A

3x

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

in Vi what deletes the current line?

A

dd

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

in vi what deletes the current line and the next four lines?

A

5dd

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

in vi what deletes from the current cursor position to the beginning of the next word?

A

dW

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

in vi what deletes from the current cursor location to the end of the current line?

A

d$

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

in vi what deletes from the current cursor location to the beginning of the line?

A

d0

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

in vi what deletes from the current cursor location to the first non-whitespace character in the line?

A

d^

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

in vi what deletes from the current line to the end of the file?

20
Q

in vi what deletes from the current line to the twentieth line of the file?

21
Q

what does d do in vi?

A

cuts and stores in p

22
Q

in vi what copies the current line?

23
Q

in vi what copies the current line and the next four lines?

24
Q

in vi what copies from the current cursor position to the beginning of the next word?

25
in vi what copies from the current cursor location to the end of the current line?
y$
26
in vi what copies from the current cursor location to the beginning of the line?
y0
27
in vi what copies from the current cursor location to the first non-whitespace character in the line?
y^
28
in vi what copies from the current line to the end of the file?
yG
29
in vi what copies from the current line to the twentieth line of the file?
y20G
30
in vi what pastes the copied text on the line below the cursor? above?
p for below. P for above
31
in vi what command joins one line with the one below it
J (note capitalization)
32
in Vi, searching within a line and repeating search
f. so fa would find the first a. repeat by pressing ;
33
Searching the entire file in Vi
/ followed by the word or phrase to be searched for followed by the enter key. repeat with n
34
Give an example of Global search and replace for Line with line in vi:
:%s/Line/line/g
35
What allows for substitution confirmation in vi?
add c to the end of the substitution chain. I.e :%s/line/Line/gc
36
Replace Confirmation key that perform the substitution?
y
37
replace confirmation key that skips this instance of the pattern?
n
38
Replace confirmation key that performs the substitution on this and all subsequent instances of the pattern?
a
39
Replace confirmation key that quits substituting
q or Esc
40
replace confirmation key that perform this substitution and then quits?
l
41
Replace confirmation key that scrolls down and up respectively. This is useful for viewing the context of the proposed substitution.
ctrl-e, ctrl-y
42
in vi to switch from one file to the next
:bn
43
in vi to move back to the previous file
:bp
44
in vi, we can view a list of files being edited with the
:buffers
45
opening additional files in vi for editing
:e followed by file
46
What does :r do in vi?
"short for "read" inserts the specified file below the cursor position.
47
what does :w do?
without anything after it it will save the file. But it can also save the file as whatever you type after it.