This VIM trick BLEW MY MIND

preview_player
Показать описание

I've been using vim for 10+ years now, and I gotta say, I still learn something new every once in a while. And recently, I realized something about macros, and registers, that BLEW MY MIND. Check out this video on why vim macros and registers are probably a LOT simpler than they seem.
Рекомендации по теме
Комментарии
Автор

Another approach is to press qA (where A is the capital letter of the register where you saved the macro) and then press J. This appends J to the end of the sequence, resulting in: A, ^[J

_Grish
Автор

BTW, you can just use `%s` as the whole file selector and replace newline with comma space: `:%s/\n/, /<CR>`

Rizhiy
Автор

I try to avoid yanking all over the place, for legal reasons

kodefood
Автор

You can even use @a at the end of the macro itself (so end the recording with @aq) - just make sure the "a" register is empty before recording (by typing qaq). Once called, it will repeat itself to the end of the file. In this specific example you would end up with a comma at the end, though, which is probably not what you want.

achimwasp
Автор

Tip: after you invoke @a the first time, which requires three button presses, you can then just press "." by itself to repeat the last command. One button press; and hold the key down for auto repeat. Helping those oldies with much more than 15 years programming experience, and their arthritic wrists and hands 😂

fed-yum
Автор

"I've yanked all over the place"

phrasing!

ChrisCox-wvoo
Автор

A couple extra tips:

- To append to a register you can use the capitalized letter "Ay
- In this case add to the macro with qA

- If you need to edit it, you can paste straight from the register with "ap

GinoFazari
Автор

this is what i love about vim. you think you're efficient already, but there's always a new neat trick to learn every so often. :)

josephangelodelosreyes
Автор

Coincidently, I learned the same trick this week and was like "ig this vim journey ain't ending soon"

vivianludrick
Автор

This absolute CHAD, 0 care havin' ass beast, actually listed god damn 'meth' in his supposed shopping list. Your humor bro - I'll never get tired of it 🤣🤣🤣

Hellbending
Автор

I've been a developer for 38 years.
Hearing "15 years" and then "I'm getting so old" was ridiculous.

JarheadCrayonEater
Автор

i love learning this native vim things rather then spamming plugins into my workflow, thanks

lileightright
Автор

i get this tutorial is for editing vim buffers and it was just an example, but the actual easiest way to do this is to type ":%s/\n/, " instead. substitute, match newline, replace with comma space.

abagfchips
Автор

You could also have tried qA.

Like when you yank into an upper case registry it will append what you do to the registry rather than overwriting it.

silak
Автор

That's huge as I can basically have a "macro.txt" file where I can save a bunch of macros and then just open the file and copy the actions in registries... love it.

Temet
Автор

It’s so intresting seeing you film this live on twitch. Such an inspiration

theIbraDev
Автор

You can also use ctrl-f to edit command-line mode commands or searches using vim motions! Eg :”compliaced command with mistake” then “ctrl f” to edit, then enter to run. Works with /“complicated search” too i think.

the edits happen in whats called the “command-line window”.

ctrl c (or :q) exits the command-line (or search) editing mode. (ie it exits the “command-line window”).
edit: to learn more run “:help c_CTRL-f”!

bambitsunami
Автор

Man, Vim never seizes to surprise me. There's always more to learn!

henrymisc
Автор

You pasted the register using the :put command, and I hadn't seen this before. I just use the inverse of yanking to the register, and paste from it using: "ap to paste from register a.

tristansnow
Автор

the number of times I've deleted a line to paste something in its place only to realise I just copied that line and pasted it back...
Sideaffect of this video is I now know how to access multiple clipboard buffers and I will be abusing that.
fantastic video

noitibmar