Hacker News new | ask | show | jobs
by earenndil 2380 days ago
> In Vim I'd press `j` to get to the first entry, then `A,<esc>` to append the `,` after the first one, then `j.` to move down and repeat the action. I then press `j.` a bunch more times (which is really easy to do rapidly with your index and ring finger on Qwerty) and in 2 seconds I'm done. Vim's `.` to repeat the last action is really powerful and can save you a ton of time for small ad-hoc edit repetitions that don't warrant doing a full macro with `q`.

Eh. I'd probably do 'qqA,<esc>j0q', and then '8@q'.

That's also probably not the best example, since that's also trivial if you have an editor supporting multiple cursors.

3 comments

That's hardcore, I would rarely use a macro for something like that :)

That said, I think multiple cursors are the greatest addition to text editing since, well, vim. I was an enthusiastic user of Sublime Text 1, right before I learned about vim.

Luckily, vim has multiple cursor support, which is... decent. Not great, but decent. I actually think that the only thing that makes multiple cursors more awesome, is being able to combine them with vim's commands, since multiple cursors rely on you being able to do precise things at each cursor, and vim gives you the language for it.

> That's also probably not the best example, since that's also trivial if you have an editor supporting multiple cursors.

Yeah, it's hard to come up with a decent example because I don't even think about it any more, it's just burned into my fingers. I just know how excruciating it feels to edit without Vim (I even wrote that last comment in Vim and then copied it into the browser because writing it in a text field is miserable).

I long ago created a special script (in Macos it's via something called Hammerspoon, I used to have a Windows version).

It basically gives vim-like keys anywhere you want, when holding down the caps lock key. So e.g. caps+h/j/k/l are movement keys.

It goes a lot farther than that: I have a key to delete a line, a key to select a word, a key to go up/down by 4 lines, a key to delete the last word, etc. I even mapped caps+f to jump forward 20 characters (to badly simulate using 'f [letter]' in vim).

This makes so it I never have to leave home position on the keyboard, because while holding caps I have all the movement keys I want at my disposal. It's a total lifesaver, and the only way I can effectively use a keyboard outside of vim :)

I guess even easier would be to go to the visual mode, then selecting all the lines and append the commas all at once :)

<c-v>8j$A,<esc>

Isn't `$` is redundant
Not in visual mode.