by f0r · 14y ago · 0 comments
1. Basic commands.
2. Syntax to chain basic commands.
3. Ability to form other commands from basic commands.
4. Way to write macros.
Instead most vim tutorials I have read present with a list of several commands to memorize and then a cheat sheet to navigate you through a jungle. Often they are letters, and not meaningful words. So they are difficult to put into ones brain. Couple that with vim's modes. And you are set with a perfect recipe for disaster in case of a new bie.If vim is indeed speaking a language than manuals and tutorials teaching it, must explain how to speak that language.
This is 2012 and the need to memorize commands, and read cheat sheets to edit text doesn't belong to our times.
What I seem to get is vim aims to provide sed, grep, tr, cut etc kind of tools inside a text editor in form of some interplay of letters and words. How I haven't figured out till today's date.
Every time I've tried to learn vim, I've quit trying to memorize 'yy P...' kind of commands. That happens as I first can't memorize random arrangement of characters. Secondly if its not random, I've not understood how to arrange and use those letters to make meaningful commands.
$ vimtutor
2. "Syntax to chain basic commands" is what you get when you think about what you are going to do. Like in any spoken or written language: "copy this line and paste duplicate it 10 times above" would be yy copy this line
10P paste above, 10 times
You have verbs (yank, paste, delete, join, move down…), direct objects (this word, this line, this html tag, this function, this paragraph…), indirect objects (up to this word, between line y and line x…) and, well… "counts" to do all that multiple times.Vim's language is a lot more natural and intuitive and efficient than any variant of Cmd+Left - Shift+Ctrl+Right - Right - Cmd+c - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v - Down - Cmd+v
Saying it's too arcane/complex/hard is just lying or being lazy.
3. "Ability to form other commands from basic commands" is achieved by writing small (or big) functions and bind them to your own commands.
4. "Way to write macros" is by not writing macros. You record a sequence of commands/keystrokes and run it later:
qa record a macro in register a
yypj duplicate this line and move to the line below
q stop recording
10@a apply the macro 10 times
No need for a cheat sheet if you are commited and don't rush it.#2 doesn't really exist, so no need to learn it.
#3 is just using the commands in sequence. They aren't new commands.
#4 is advanced and I've never had a need for it yet.
Let's pick some apart:
ddp:
dd - delete line
p - paste line below
This swaps a line because when you delete a line, the line below it moves up and you end up on that line. When you paste an entire line, it pastes to the next line.
ddkP:
dd - delete line
k - move up 1 line
P - paste line above. (Shift usually means 'opposite direction', so it pastes above instead.)
I don't think of these as commands as such. I just think, I want to delete this line, and then I want to place it here. He's providing these as commands to show that Vim can handle the same features as Sublime Text, but he's doing it in a non-Vim way, as far as I'm concerned.
You don't memorize non-basic commands. You just use basic commands until you get what you need, and it happens that the advanced commands for most other editors can be done with just the basic commands of Vim.