From StackOverflow:
Your problem with Vim is that you don’t grok vi.You mention cutting with
yy
and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However,yy
is only one of many way to yank text into the anonymous copy buffer (or “register” as it’s called in vi).The “Zen” of vi is that you’re speaking a language. The initial
y
is a verb. The statementyy
is a simple statement which is, essentially, an abbreviation for0
y$
:
0
go to the beginning of this line.y
yank from here (up to where?)$
up to the end of this line.This can also be expressed as
dd
P
(delete the current line and paste a copy back into place; leaving a copy in the anonymous register as a side effect). They
andd
“verbs” take any movement as their “subject.” ThusyW
is “yank from here (the cursor) to the end of the current/next (big) word” andy'a
is “yank from here to the line containing the mark named ‘a‘.”If you only understand basic up, down, left, and right cursor movements then vi will be no more productive than a copy of “notepad” for you.
[ NOTE: You may also be interested in my Vim Primer here. ]