Basics of Vi Flashcards

How to use the VI editor

1
Q

How can you open vi editor?

A

just type vi

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

How can you see a file with vi in read-only mode?

A

with “view” command

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

What are the modes in the VI Editor

A

Command, Insert, Line mode

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

What are the keys for moving top, down, left, right in vi?

A

k -> Up
j -> Down
h -> Left
l -> Right

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

What’s the use of w and b keys in vi?

A

w moves one word to the right, b moves one word to the left

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

How to go to the beginning of a line in vi?

A

With ^

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

How to go the end of a line in vi

A

$

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

How to start Insert mode in vi?

A
There are multiples ways:
i   ->  Insert at the cursor position
I   ->  Insert at the beginning of the line
a  -> Append after the cursor position
A  -> Append at the end of the line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to enter Line mode in vi

A

Use the colon character :

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

How to exit Vi?

A

:q

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

How to exit without saving changes in vi?

A

:q!

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

How to exit saving the changes in vi?

A

:wq!, even better a shorcut is :x

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

How to save a file in vi?

A

:w, this one forces the action :w!

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

How to delete a character in vi?

A

x

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

How to delete a word in vi?

A

dw

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

How to delete a line in vi?

A

dd

17
Q

How to delete from the current position in vi?

A

D

18
Q

What is r for in vi?

A

replace the current character

19
Q

What is cw for in vi?

A

change the current word

20
Q

what is cc for in vi?

A

change the current line

21
Q

what is c$ for in vi?

A

change the text from the current position

22
Q

What is ~ for in vi?

A

Reverse the case of a character

23
Q

How do you copy the current line in vi?

A

yy

24
Q

How do you paste the most recent deleted or yanked text in vi?

A

p

25
Q

What does / do in vi?

A

Start a forward search

26
Q

What does ? do in vi?

A

Start a reverse search

27
Q

How to undo and redo in vi?

A

u for undo, CTRL+R to redo