Intro to Vim Macros

  Рет қаралды 130,230

bashbunni

bashbunni

Жыл бұрын

#short #shorts #neovim #programming #vim

Пікірлер: 170
@devlinbowman5251
@devlinbowman5251 9 ай бұрын
You can make your macros recursive by calling the assigned register during recording. Eg; qw + the things you want + @w +q to stop recording. This way the macro calls itself on completion.
@QckSGaming
@QckSGaming 3 ай бұрын
But when does it stop?
@devlinbowman5251
@devlinbowman5251 3 ай бұрын
@@QckSGaming Usually at EOF. But, experimenting with this, I’ve found it can do some funky things in certain situations. The proper course of action would usually be to make file wide changes via a command, which is both operationally faster and computationally safer, but sometimes you’ve set up a good macro and decide you’d rather get a cup of coffee than repeat the last 30 keystrokes. However, upon further consideration of your question, I should probably look at the documentation to be sure don’t this isn’t an issue.
@ocaly
@ocaly 27 күн бұрын
​@@devlinbowman5251 wait why would you want this you can "69420@w" to do the same. Recursion sounds dangerous, what if it deletes everything and you want to undo..?
@SayfSentinel
@SayfSentinel 11 күн бұрын
There is no need to go down then at the beginning of the line You can just escape then enter it will put you at the beginning of the line
@vikingthedude
@vikingthedude Күн бұрын
I like to imagine that vim has all these weird features whose documentation only exists in discussion forums and comment sections
@ghun131
@ghun131 Ай бұрын
This is black magic, the dark art I want to learn
@scally9341
@scally9341 Жыл бұрын
holy shit never even looked into what the recording q thing is. legend.
@bashbunni
@bashbunni Ай бұрын
Guys, of course you can use visual block mode for this, I’m just showing the most basic example of macros in under 60s. Cmon 😂
@maxz999
@maxz999 Жыл бұрын
I had a realization at the end of this clip… I have been calling my macros repeatedly one by one for far too long now. Don’t know why I didn’t notice this earlier.
@paulgupta2454
@paulgupta2454 7 ай бұрын
sometimes it's nice to just bash '.' repeatedly one after another.
@TheKuhtaMusic
@TheKuhtaMusic 5 ай бұрын
yeah, I have been doing @@ repeatedly as well. Thanks for showing this!
@theodorealenas3171
@theodorealenas3171 Жыл бұрын
Today Vim macros helped me a lot. :e /tmp/a :.!ls -1 And then I recorded a macro. This /tmp/a file now contained a list of files. The macro would use that list to jump to a file, call another macro, and come back. I wanted to remove the header and footer from all the HTML files of a directory. Then I wanted to do another operation to all the files, so I kept the outer macro and changed the inner. It was an adventure. The context of why I wanted to do it was terrible, but doing it was fun.
@QuantPhilosopher89
@QuantPhilosopher89 26 күн бұрын
You can do the same with visual block mode: ctrl + V, then go down to whatever line you want to insert content into, then type an I, then start typing and click ESC once you're done.
@hamm8934
@hamm8934 Жыл бұрын
You can also use ctrl + v to highlight the first character of each line and then do shift + i. Type in your bullet points. Hit esc, and then bam you have your check list. I need to play around with macros for sure though
@alacritty
@alacritty Жыл бұрын
Thanks for the tip! Very fast and simple.
@brendencallahan242
@brendencallahan242 Жыл бұрын
ctrl + q if you happen to be on windows (even wsl2) (this only affects the windows terminal not other terminals or guis)
@hamm8934
@hamm8934 Жыл бұрын
@@brendencallahan242 maybe you have remapped ctrl + v in your config, ctrl +v works for me both on windows and Unix
@brendencallahan242
@brendencallahan242 Жыл бұрын
@@hamm8934 Nope. It's from the 'new' windows terminal. If you are using a different terminal or a gui it won't affect you. I tried to link a so thread but KZbin deleted the comment.
@hamm8934
@hamm8934 Жыл бұрын
@@brendencallahan242 oh interesting, thanks for the info. I use Windows Terminal at work instead of the built in command line of power shell so I must have incidentally avoided the conflict
@ProjectileGrommet
@ProjectileGrommet 6 ай бұрын
Relative line numbering is perfect for this
@bashbunni
@bashbunni 6 ай бұрын
I will not!!1!
@eamonburns9597
@eamonburns9597 5 ай бұрын
Yeah, it's great. Although, depending on how you record the macro, you can get "off-by-one errors" if you go by the literal numbers. Just something to be aware of
@anthonydesouza9983
@anthonydesouza9983 5 ай бұрын
Macros stop if they can’t go further, so just do 100@q and it will stop after “j” can’t go to the next line.
@eamonburns9597
@eamonburns9597 5 ай бұрын
@@anthonydesouza9983 that only helps if the section you are trying to change is at the end of the file, which, most of the time, it isn't
@alacritty
@alacritty Жыл бұрын
Love these shorts and learning more and more about vim
@Rh0mbus
@Rh0mbus 10 ай бұрын
This is awesome, great example and I can already see how ridiculous the potential is
@wesleychaffin4029
@wesleychaffin4029 8 ай бұрын
This was a helpful lil intro to a vim macro! Thanks!
@Redyf
@Redyf Жыл бұрын
I love your videos, thank you for sharing these tips!
@GabeKMusic
@GabeKMusic 6 ай бұрын
tip: + moves down a line and moves your cursor to the first char. saves a key press compared to j0
@jacderida
@jacderida Ай бұрын
Wow, nice! Been using nvim/vim since ~2014 and I never came across this before.
@Jag3rm3ist3r
@Jag3rm3ist3r Ай бұрын
I - [ ] j You don't need to move to the start of the line if you jump there when you switch to insert mode.
@theMRcapitanBANANA
@theMRcapitanBANANA Жыл бұрын
This has to be the best thing ever, I didn’t even knew it was posible!
@ascourter
@ascourter Жыл бұрын
Macros have been on my list for awhile. Thanks for the great intro!
@MilanGunasekera
@MilanGunasekera 7 ай бұрын
Another useful way to do this could be by using a Visual Block . When in this mode, key down to the bottom with G, then press "I" to enter insert mode. You can then insert the - [ ] and exit back to normal mode with ESC
@TheGrouchDnD
@TheGrouchDnD 7 ай бұрын
Saving this for when I inevitably need this
@ilyeshammadi7278
@ilyeshammadi7278 Жыл бұрын
Nice. A much nicer way to avoid adding the j will be to use parallel macros with :3,8norm @w without including the j when recording the macro
@Al-ws7cn
@Al-ws7cn 5 ай бұрын
After all this time of ignoring whatever this recording feature is I finally learn it, my life is complete. Amazing vid.
@romanferguson4032
@romanferguson4032 5 ай бұрын
my mind has exploded
@JayJay-rk2xx
@JayJay-rk2xx 10 ай бұрын
😮 I'm in awe
@Steliosgiannatos
@Steliosgiannatos 4 ай бұрын
Vim is so powerful, but daunting to start.
@celestialbeing4767
@celestialbeing4767 3 ай бұрын
Mad cool
@juanmacias5922
@juanmacias5922 Жыл бұрын
Macro-mazing!
@maxwebstudio
@maxwebstudio 8 ай бұрын
Nice one
@js-ny2ru
@js-ny2ru Жыл бұрын
That was so cool! Thx Bunni :)
@emanuelavilesarchivado
@emanuelavilesarchivado 11 ай бұрын
i love it! 😎❣️
@zicraftian
@zicraftian 2 ай бұрын
That is just so cool! I had no idea vim had a feature like this!
@kitti.crafts
@kitti.crafts 7 ай бұрын
❤It helped me a lot.
@samdelamarter4557
@samdelamarter4557 Жыл бұрын
Great content! Really like this style of short.🐰🧡
@n0kodoko143
@n0kodoko143 Жыл бұрын
In the words of Prime "macro pressure!"
@FakeDumbDummy
@FakeDumbDummy Жыл бұрын
hell yeah
@buttface6t4
@buttface6t4 Жыл бұрын
this was super helpful
@user-xd5gd4pc9h
@user-xd5gd4pc9h Жыл бұрын
Cool!😁
@HomeAlbadawi
@HomeAlbadawi 9 ай бұрын
Thanks this video was helpful
@Yupppi
@Yupppi 7 ай бұрын
Thanks, I've been learning and constantly hitting recording accidentally and wondering how to use it.
@yuvrajpawar4177
@yuvrajpawar4177 Жыл бұрын
Loved your video with the legend Telescopic TJ♥️. Please try DWM as well you will love it. Absolute respect for your programming abilities ♥️
@c1dk1n
@c1dk1n 4 ай бұрын
Love your work
@lebenebou
@lebenebou 11 күн бұрын
instead of adding j0 to the end of the macro, you can visually select the lines you want to execute on, and type the command :normal @w it will run the macro on the selected lines
@aquepaique
@aquepaique 4 ай бұрын
ctrl-v + G + I + *insert mode* - [ ]
@fuzzy-02
@fuzzy-02 8 ай бұрын
*faith restored* Cute video.
@stuckoverflaws
@stuckoverflaws Ай бұрын
very helpful! thanks
@vikingthedude
@vikingthedude Жыл бұрын
As someone who’s been using vim for about 2weeks now I definitely needed to hear about macros
@vikingthedude
@vikingthedude 7 ай бұрын
As someone who’s been using vim for 5months now, I definitely consider macros my bread and butter
@samarthnagar2939
@samarthnagar2939 6 ай бұрын
Ad someone who is using vim for an year it definitely usefull to learn about macros
@jsm33t
@jsm33t 6 ай бұрын
As someone who will use vim someday this will be helpful
@vikingthedude
@vikingthedude Күн бұрын
As someone whose been using vim for a year now, i do think macros are goated
@sidiqalfiansyah9321
@sidiqalfiansyah9321 11 ай бұрын
thanks
@j1d7s
@j1d7s Жыл бұрын
Thanks for the video! I understand that for the short time available you could not show a more complicated macro. But just as @Hamm said, this example would have been the perfect use case for using block mode. So anyone trying out macros for the first time, still check if another way of doing it is easier / faster!
@connemignonne
@connemignonne 13 күн бұрын
there's also a much easier way to do this with visual block mode: ctrl + v (to enter visual block mode) press j to go down however many lines you need (or with a number like 5j to jump 5 at a time) Shift + I to enter insert mode type the checkbox stuff and when you hit escape it will be inserted on every line you had selected in the visual block
@lightsite999
@lightsite999 29 күн бұрын
Blown my mind was
@pluto3531
@pluto3531 10 ай бұрын
ty
@cozyfog
@cozyfog 4 ай бұрын
You can do the same with ctrl+v for visual block and shift+i to insert
@thecodebear
@thecodebear Жыл бұрын
Noice
@marcosduvannitolarodriguez1933
@marcosduvannitolarodriguez1933 Ай бұрын
Thanks
@asadanik5987
@asadanik5987 3 ай бұрын
You are JavaScript ❤.. difficult to catch you up. Still loving you silently
@bashbunni
@bashbunni 3 ай бұрын
That is so mean 😭
@alexfu2422
@alexfu2422 2 ай бұрын
Control - v select first character of each line and Shift I to insert - [ ] and hit escape, done. This is more intuitive but more typing.
@olivierlasne2346
@olivierlasne2346 Ай бұрын
I have been wondering for so long what that "macro recording" was. When I accidentally type 'q' without the ':' to quit vim 😅
@sebaszwarc
@sebaszwarc 3 ай бұрын
Other editors was written by developers to help you, in vim you must help yourself
@bashbunni
@bashbunni 3 ай бұрын
Vim is a lifestyle
@sergp7480
@sergp7480 Жыл бұрын
Mix macro with norm and replace - very powerful combo. Nice editing btw 😊
@bashbunni
@bashbunni Жыл бұрын
ouuuuuu
@sergp7480
@sergp7480 Жыл бұрын
@@bashbunni I also recorded short about macro but with norm
@terry2295
@terry2295 Ай бұрын
Using VIM for that is insane to me, like I understand using it for complex scripting but plain text?
@patrickraedler3656
@patrickraedler3656 Жыл бұрын
Nice, I didn't know that! Thanks for sharing :) Also, which is that font that you are using? Looks really nice!
@bashbunni
@bashbunni Жыл бұрын
Blex Mono nerd font :)
@PofMagicfingers
@PofMagicfingers 2 ай бұрын
Nice!
@carlossaenz8204
@carlossaenz8204 4 ай бұрын
vim btw
@ashwiniabhishek1504
@ashwiniabhishek1504 22 күн бұрын
When she started to play the recording, my laptop hung because of program I was running and the video started repeating in strange manner, I though what a video effect she has put to show the replay option, but when it became too monotonous and then I realised my laptop is hung ;).
@RolexChan
@RolexChan 6 ай бұрын
漂亮😻谢谢☺️
@saishinnthant4839
@saishinnthant4839 27 күн бұрын
which font do you use in this video?
@comosaycomosah
@comosaycomosah 21 күн бұрын
Anddd I somehow end up with 4 boxes in front of the word instead 💀and the 2nd attempt ended up with the boxes going down this time but off placed by one character into each word instead of in front of the word lmao I need practice
@re1konn
@re1konn 10 ай бұрын
An easier way if using macros: Record the action that you want on a certain line. That should not include going to the next line. Now, select all the lines you want that action to be repeated on. Type :norm @ and then press enter.
@nekoill
@nekoill 4 ай бұрын
Wouldn't it be easier if you first just hit Ctrl+v and then whatever you need to press to get to the end of your list, then hit capital I, type `- [ ]`, hit Esc and be done?
@bashbunni
@bashbunni 3 ай бұрын
It’s so funny because originally the video included me saying “this is kind of a bad example because I could just use visual block to add these checkboxes, but I want to keep the example as simple as possible” but it made the short too long iirc, so I just decided not to include it. Now I see so many comments being like “but you could just…” and I’m like ahhh I knew it would come!!
@robertholtz
@robertholtz Ай бұрын
Two words for you… multiple cursors.
@user-me8dk7ds7f
@user-me8dk7ds7f Ай бұрын
visual box I think would be easier here.
@heheitskenny
@heheitskenny 3 ай бұрын
Does anyone know what colorscheme is used in the demo here? Thanks
@bashbunni
@bashbunni 3 ай бұрын
Catppuccin :) the best!
@darklightnessful
@darklightnessful Ай бұрын
Norm is faster or visual insert
@GrandNecro
@GrandNecro 5 ай бұрын
i would have done ctrl v and I to insert the columns of text
@YourAvgjoe
@YourAvgjoe 10 ай бұрын
I use space v to bring up a terminal to test my code. I used to be able to click back into my code then edit. Some way I’ve disabled my trackpad, any advice?
@oglothenerd
@oglothenerd 10 ай бұрын
I use Helix. Also, did you know that the creator of Vim died recently!? 😢
@victortesla2935
@victortesla2935 7 ай бұрын
😳
@chezchezchezchez
@chezchezchezchez Ай бұрын
All this work with Xcode VIM mode?
@wl4dymir
@wl4dymir Ай бұрын
You would do this one much faster with a substitute.
@data.monoid8785
@data.monoid8785 11 ай бұрын
Ctrl+v -> 5j -> S-i -> enter text (- [ ] ) -> Esc
@oErebor
@oErebor 2 ай бұрын
What is this font ?
@chonkey
@chonkey 2 ай бұрын
Visual block mode would be faster
@user-hw3tu2gx3w
@user-hw3tu2gx3w 7 ай бұрын
Font name?
@HoranMustaplot
@HoranMustaplot 5 ай бұрын
What is the name of the font she's using here?
@bashbunni
@bashbunni 5 ай бұрын
I think it’s BlexMono nerd font - it’s been my fave for a while now
@irienas
@irienas 11 ай бұрын
Please what is the name of 𝕥𝕙𝕖 𝕥𝕙𝕖𝕞𝕖?
@shailmurtaza9082
@shailmurtaza9082 10 ай бұрын
You already know VIM macros. Why are you here? 😏
@coolguy69verycool
@coolguy69verycool 4 ай бұрын
I should learn macros, I'd do it with a command like this: ":4,8s/^/- [ ]"
@aryanmn1569
@aryanmn1569 Жыл бұрын
a real question (I'm not anti vim). why shouldn't we use multi-cursor like in vscode? where its more powerful? I mean what this get done that multi-cursors won't or does it slower?
@agfd5659
@agfd5659 Жыл бұрын
In this case, visual block mode insert (which is similar to multi cursor) would make more sense, but there are cases where macros become very useful.
@bashbunni
@bashbunni Жыл бұрын
I kept this as a suuuper basic example that can definitely be done in many ways. Macros are overkill here, but for simplicity I decided to use it as an example anyway
@aryanmn1569
@aryanmn1569 Жыл бұрын
@@bashbunni it would be nice to see an example which cant be done without multi-cursor, to really feel the power.
@agfd5659
@agfd5659 Жыл бұрын
@@aryanmn1569 So one example would be: imagine you have a comma separated values file like this: some,thing,hello world,more,stuff yet,another,line containing,imortant,values And you need to capitalize the first letter of all values in the second column like this: some,Thing,hello world,More,stuff yet,Another,line containing,Imortant,values This would be difficult (or maybe even impossible) with multi-cursor. With macros, this is easy: 1) Go to the beginning of the first line. 2) Record the macro into the s register with qsf,lvUq 3) Now apply this macro to every line in the file with :%norm@s And you're done!
@ChrisCox-wv7oo
@ChrisCox-wv7oo 8 ай бұрын
@@aryanmn1569 multicursor is really powerful, no doubt about it. the other day I had to refactor some code. we had several dozen functions that had static local variables and I wanted to pull them all out and make them class members. the variable could be defined anywhere within the function. first line, last line, middle. sometimes there were multiple statics within a single function. I ended up with the macro /static^Mdd^^p^O@q search for static keyword (/static), delete that line(dd), switch to last file which was the header (^^). paste correcting indentation ([p). return to where static was deleted from in cpp (^O). run macro again (@q). it neatly moved all the statics from test.cpp to the last cursor location in test.h. is something like this possible with multicursor?
@Dimarichek
@Dimarichek Жыл бұрын
What font do you use?
@bashbunni
@bashbunni Жыл бұрын
BlexMono nerd font
@Babbili
@Babbili 6 ай бұрын
Is there documentations for Vim, i can learn it from
@bashbunni
@bashbunni 6 ай бұрын
Try :Tutor when you’re in vim/neovim. That one is a full walk through. Also :help has a lot of great docs. There are lots of great docs online for neovim as well. Will make note of this though, might be worth listing off some of the different text-based resources for learning vim and lua
@Babbili
@Babbili 6 ай бұрын
@@bashbunni thanks
@Heart0rHead
@Heart0rHead Жыл бұрын
Any modern IDE with multiple caret support will do this faster and easier.
@chillmelon7894
@chillmelon7894 9 ай бұрын
Why not just use block?
@axewellll
@axewellll 8 ай бұрын
bad example, you don't need macros in this case
@ErdajtSopjani
@ErdajtSopjani 2 ай бұрын
wifey
@rhymeflakes
@rhymeflakes 8 ай бұрын
Is this default feature?
@bhavyakukkar
@bhavyakukkar 7 ай бұрын
yes
@pranaydeshmukh8207
@pranaydeshmukh8207 11 ай бұрын
What is Vim macros
@421sap
@421sap 4 ай бұрын
God bless you in Jesus' Name Amen ✝️
@Tanmaydeshpande-nl5jy
@Tanmaydeshpande-nl5jy 21 күн бұрын
no way you qw and not qq
@grim.reaper
@grim.reaper Жыл бұрын
I love this 🥹
@Luanxxxxx
@Luanxxxxx 6 ай бұрын
I don't care that you're pretty, I only followed because of the vim macro I love
@dogaarmangil
@dogaarmangil 6 ай бұрын
Big omissions: You didn't say which mode are you starting in, and you aren't showing the status line that indicates the current mode.
@jiangyz
@jiangyz 2 ай бұрын
Such a cute girl to demonstrate vim! I came out 4 ways to do kind like this by using macro (from the comments and my experience): (Substitute "- [ ] " with "- " to simplify the demo , using q as the macro register.) 1. Repeat Apply qqi-q j@q j@@ 2. Batch Apply qqi-q u vap @q 3. Recursive Apply qqi-j@qq uu @q 4. Range Apply qqi-q u :1,$normal@q
@RuslanKovtun
@RuslanKovtun Жыл бұрын
Very very very bad example because Ctrl+V followed by "I- [ ] " will do the same and way easier for this example. Macros are for more complicated things.
@bashbunni
@bashbunni Жыл бұрын
Ah yeah I did have a disclaimer about it not being the best example at the beginning of the video originally, but in the interest of keeping the example as simple as possible, I decided to just leave it despite being able to accomplish the same thing with visual block. I don't think that makes it a bad example, just the simplest possible example for how macros work :)
5 Command Line Tools That Boost Developer Productivity (2023)
8:02
30 Vim commands you NEED TO KNOW (in just 10 minutes)
10:27
typecraft
Рет қаралды 71 М.
Me: Don't cross there's cars coming
00:16
LOL
Рет қаралды 15 МЛН
Who has won ?? 😀 #shortvideo #lizzyisaeva
00:24
Lizzy Isaeva
Рет қаралды 34 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 21 МЛН
Zed “kills” VSCode
12:10
Alex Ziskind
Рет қаралды 656 М.
update: doom emacs && dotfile management
7:59
bashbunni
Рет қаралды 34 М.
How Neovim saved me at least 30 minutes today
8:12
Rasmus Bergström
Рет қаралды 10 М.
UI Libraries Are Dying, Here's Why
13:28
Theo - t3․gg
Рет қаралды 278 М.
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 928 М.
Vim vs NeoVim, What's the Difference?  Which Should You Use?
10:29
Mental Outlaw
Рет қаралды 314 М.
I tried Neovim Distributions so you don't have to
9:12
typecraft
Рет қаралды 143 М.
Hack your brain with Obsidian.md
11:53
No Boilerplate
Рет қаралды 1,9 МЛН
Tmux will SKYROCKET your productivity - here’s how
10:02
typecraft
Рет қаралды 77 М.
The perfect imperfection of Google's Material You
15:47
David Imel
Рет қаралды 409 М.
Первый обзор Galaxy Z Fold 6
12:23
Rozetked
Рет қаралды 313 М.
WATERPROOF RATED IP-69🌧️#oppo #oppof27pro#oppoindia
0:10
Fivestar Mobile
Рет қаралды 17 МЛН