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?

A

dG

20
Q

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

A

d20G

21
Q

what does d do in vi?

A

cuts and stores in p

22
Q

in vi what copies the current line?

A

yy

23
Q

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

A

5yy

24
Q

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

A

yW

25
Q

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

A

y$

26
Q

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

A

y0

27
Q

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

A

y^

28
Q

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

A

yG

29
Q

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

A

y20G

30
Q

in vi what pastes the copied text on the line below the cursor? above?

A

p for below. P for above

31
Q

in vi what command joins one line with the one below it

A

J (note capitalization)

32
Q

in Vi, searching within a line and repeating search

A

f. so fa would find the first a. repeat by pressing ;

33
Q

Searching the entire file in Vi

A

/ followed by the word or phrase to be searched for followed by the enter key. repeat with n

34
Q

Give an example of Global search and replace for Line with line in vi:

A

:%s/Line/line/g

35
Q

What allows for substitution confirmation in vi?

A

add c to the end of the substitution chain. I.e

:%s/line/Line/gc

36
Q

Replace Confirmation key that perform the substitution?

A

y

37
Q

replace confirmation key that skips this instance of the pattern?

A

n

38
Q

Replace confirmation key that performs the substitution on this and all subsequent instances of the pattern?

A

a

39
Q

Replace confirmation key that quits substituting

A

q or Esc

40
Q

replace confirmation key that perform this substitution and then quits?

A

l

41
Q

Replace confirmation key that scrolls down and up respectively. This is useful for viewing the context of the proposed substitution.

A

ctrl-e, ctrl-y

42
Q

in vi to switch from one file to the next

A

:bn

43
Q

in vi to move back to the previous file

A

:bp

44
Q

in vi, we can view a list of files being edited with the

A

:buffers

45
Q

opening additional files in vi for editing

A

:e followed by file

46
Q

What does :r do in vi?

A

“short for “read” inserts the specified file below the cursor position.

47
Q

what does :w do?

A

without anything after it it will save the file. But it can also save the file as whatever you type after it.