Hacker News new | ask | show | jobs
by wccrawford 5120 days ago
Yup, you start with #1 there.

#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.

1 comments

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.

I'm all ears. What would be the Vim way?

As I said, learning the basic commands and using them. There's no need to remember a key combo for 'swap lines' because it's just 2 basic commands used in succession. I never even think of it as 'swap lines' because what I want to do is remove a line, then place it somewhere else. And that's what the commands are in Vim to make it happen.
That's how I constructed the above list in the first place, but I get what you mean; you shouldn't be learning these as Street Fighter-like combos.