Using vi for your simple, day-to-day editing needs

My favorite editor isn’t vi, but I’m still using it at least a couple of times each day. It’s a short two character command, it’s always available and it starts fast.

I have used it for decades and still, I only know these commands. I really don’t need to learn any others, contrary what some of my friends tell me.

Need to know

j = move down
k = move up
l = move right
h = move left
i = go into “insert” mode
= go into “command-line” mode
ESC = go out of current mode
x = delete character
wq! = save file and quit (when in command mode)
q! = quit (when in command mode)

Good to know

{number}G = goto line
yy = copy line
dd = delete line
p = paste line below
P = paste line above
r = replace character
A = go into “insert” mode and append to end-of-line
/ = go into “search” mode

That’s it .. you might want to check out variants of these commands e.g. “5dd” to delete five lines, “4yy” to copy four lines.

If you need a list of all commands, look up the index help page in the vim (you are probably using vim and not vi) documentation using:

: help index

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.