Is there some pattern behind the many VIM commands?
editor, vim
Solution
Well, there is obviously a finger position pattern behind h, j, k, l.
The fact that ^ goes to the beginning of a line and $ goes to the end is patterned on common regular expression syntax.
Ctrl-F and Ctrl-B page forward and back, and that's fairly intuitive.
i inserts (before) and a appends (after the cursor). Similarly, I inserts at the beginning of the line, and A appends at the very end.
> and < indent and outdent, respectively. That's also kind of intuitive.
But on the whole, many of the other commands are on whatever keys were left – it's hard to find an intuitive mapping between the letters of the alphabet and an editor's commands.
Repeat counts are always entered before a command, and mostly repeat the command that many times, but in some cases do something clever but analogous.
I think the secret to not going crazy over `vi` is to start out with only a small handful of commands. I have a lot of colleagues who don't know to do anything other than
- move the cursor around using the arrow keys (you don't have to use h, j, k, l);
- insert with i, delete with Del (you don't have to use x);
- delete a line with dd
- get out of input mode with Esc
- get out of vi with :x (exit) or q! (quit, and throw away my changes!)
Because I'm much smarter, the additional commands I know and use are:
- go to the top of the file with gg, the bottom with G. I can go to a specified line number with (line-number)G.
- copy a line with y (yank), paste it with p
- change a word with cw, the rest of the line with C
- delete a word with dw, the rest of the line with D
- I sometimes use . to repeat the last command, or u (undo) if I messed up.
When you have occasion to use other commands, you can teach them to yourself one by one as needed.
Problem
I have to add a VIM personality to an IDE. I never used VIM for more than the most basic edits and i'm now overwhelmed by the complexity of the command structure. Is there any overall structure for the combination of counts moves and insert/delete commands? I just can't see the wood for the trees.