3 ms·
Oh man, I use markers all the time. ma y'a mark a spot, then yank or delete everything to that line. Way easier to do it accurately rather than 13yy or howeve
by soperj 1y ago
Oh man, I use markers all the time.
ma
y'a
mark a spot, then yank or delete everything to that line. Way easier to do it accurately rather than 13yy or however many lines you're yanking.
- zeke 1y agoYou can use <shift>v then move to your start line and type y or d. This way you see the text marked before yanking or deleting. <control>v is similar. And gv will reselect the marked area.
- dwater 1y agoAnd if you have line numbering on you can y123G. I learned enough Vim 25 years ago to be good enough and I'm happy I did. When I was writing code every day I picked up a little more but I've lost most of it, and what I'd want people to know who are considering it is you never need to be a Vim Master. You can learn enough Vim in 30 minutes to make it beneficial to you for the rest of your life.
- Izkata 1y agoI turn on relative line numbering so that y123G might be y8j and vim will show me the 8.
- ramses0 1y agoma, mb, mc => 'a, 'b, 'c => ...just being able to "tag" each of the three functions you're working with (comparing, copying, moving code, whatever) it's eventually worth it to get them into your muscle memory. And once you "get" marks, then you "get" registers "for free".
- soperj 1y agoand this is why i always read vim articles... i've never used registers in my life.
- ramses0 1y agoI'll use them in macros fairly frequently: vawy'f => function name, vi{y'b => body, vi(y'a => args ...or y'x to keep something kindof handy that I can drop in at the right place (sometimes with a macro...) qadi('xpq => @a => @@... (Record macro "a", delete inner parentheses, paste from the "x" register, stop recording => play macro "a" => play last macro...) If I keep "x" clean/protected then I can delete or edit the rest of the time all willy-nilly and not worry about clobbering what I'm trying to paste into the right spots.
- asimovDev 1y agoI feel so damn stupid for counting the lines with my eyes before yanking after reading this. As a staunch believer in markers, this is eye opening. I was using them just to jump between functions most of the time. This is very useful