Basics of Vi Flashcards
How to use the VI editor
How can you open vi editor?
just type vi
How can you see a file with vi in read-only mode?
with “view” command
What are the modes in the VI Editor
Command, Insert, Line mode
What are the keys for moving top, down, left, right in vi?
k -> Up
j -> Down
h -> Left
l -> Right
What’s the use of w and b keys in vi?
w moves one word to the right, b moves one word to the left
How to go to the beginning of a line in vi?
With ^
How to go the end of a line in vi
$
How to start Insert mode in vi?
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 to enter Line mode in vi
Use the colon character :
How to exit Vi?
:q
How to exit without saving changes in vi?
:q!
How to exit saving the changes in vi?
:wq!, even better a shorcut is :x
How to save a file in vi?
:w, this one forces the action :w!
How to delete a character in vi?
x
How to delete a word in vi?
dw
How to delete a line in vi?
dd
How to delete from the current position in vi?
D
What is r for in vi?
replace the current character
What is cw for in vi?
change the current word
what is cc for in vi?
change the current line
what is c$ for in vi?
change the text from the current position
What is ~ for in vi?
Reverse the case of a character
How do you copy the current line in vi?
yy
How do you paste the most recent deleted or yanked text in vi?
p
What does / do in vi?
Start a forward search
What does ? do in vi?
Start a reverse search
How to undo and redo in vi?
u for undo, CTRL+R to redo