Vi and co Flashcards

1
Q

Navigation

h , j , k , l

A

think of position on keyboard

l : moves the cursor to the RIGHT

h: (symmetrically opposite) moves cursor to the LEFT

k : moves cursor to the line ABOVE

j : (symmetrically opposite) moves cursor one line DOWN

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

Navigation

w , e , b

A

think of 1st letter of

w : next word in line

e : end of next word on same line

b : beginning of next word on same line

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

Other useful keystrokes

:q!

:w

ZZ

:e!

:!

A

:q! quit without saving changes

:w write => save changes while staying in vi

ZZ no semicolon and capitals writes the file and exits

:e! reloads the file abandoning changes made

:! run a shell command from the vi screen

NOTE: the semicolon moves the cursor to the bottom of the screen to write out command.

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

Insert, edit etc.

i

o

cw & c$

dw & d$

dd

x

A

i : insert

o : insert a line under the current line. O for the line above

cw : place cursor in a word and deletes the part to the left of the cursor. NOTE insert mode is entered subsequent.

c$ : with c$ the rest of the line to the left of the cursor is deleted. NOTE insert mode is entered subsequently.

dw : same as cw but without insert mode butting in

d$ : like c$ without the insert mode butting in

dd : deletes the cursor’s current line

x : deletes character at the cursor position

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

Search

/

?

n

A

/ (followed by string) searches forward in opened file

? (followed by string) searches backward in opened file

n repeats search (forwards or backwards)

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

From inside vi

:help <command></command></command>

A

you’re in a file opened with vi

type :help wrap

the help for the command wrap is opened and can be scrolled through.

to leave help type :q

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

So when do I use the ESC key?

A

When you want to exit the INSERT mode that you enter by typing i

By default you are in the COMMAND mode which allows you to move around, delete characters insert lines etc but not insert stuff.

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