Friday, July 20, 2018

Learning vi: mental notes

Though I use vi here and there for several years now, there's always some new trick to learn.
Lately I've had on my desk the book Learning the vi editor by Linda Lamb, published by O'Reilly.

Here I list, in no particular order, some notes as a way to reinforce what I've learned from the book. The focus is on things that called my attention, were new to me and/or that were not internalized yet in my day-to-day usage.

vi versus/and ex

ZZ = save and exit = :wq (ex command)
:e! = reload from disk
~ = toggle case
xp = transpose two characters

0 = go to beginning of line (same as ^)
W = move to the beginning of the next word, ignoring punctuation
B = move to the beginning of the previous word, ignoring punctuation
e = move to the end of the next word
E = move to the end of the next word, ignoring punctuation

. = repeat last command
Y = yy
P = put text before cursor
D = d$
C = c$
X = delete character before cursor
cc = change line = ddO = 0D
"3p = put contents of buffer number 3 (not the last buffer)
U = undo all edits on a single line
A = append at the end of the line
I = insert at the beginning of the line
s = c+space = xi = substitute character
S = cc = substitute line

50i* = insert 50 times *

ea = append to the end of a word
J = join consecutive lines

No comments: