Vi Editor Flashcards
Which is your preferred editor?
vi editor, universal editor.
What are the different modes of the vi/vim editor?
Escape, Insert and Command mode.
visual mode.
How to quit Vim without saving any changes?
:q
How can you quit Vim while saving the changes you made?
:wq, :x, :wq!, shift zz
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?
: to enter
command mode then %s/NYC/NJ/g, it replace NYC with NJ everywhere in the file (g for global).
While editing a file using vi editor and you want to change a name "Robert" to "bobby",
how would you do that?
press ce or cw while in escape mode, make sure the cursor is on Robert, then type bobby
How would you select a range of lines, copy and paste them at the end of the file?
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 would you jump from the beginning of the line to the end of a line?
press shift 4
(stays in escape mode) or shift a (goes into insert mode)
How can you jump back from the end of a line to the beginning of the line?
press 0 or shift
6 (stays in escape mode)
How would you go to the last line of the file in vi or vim editor?
press shift g
How would you go back to first line of the file in vi or vim editor?
press gg
How to shift to insert mode in Vi editor?
press i
Why do we use "!" in addition to ":w" or ":wq" to quit?
to save and quit forcefully