News for hackers. Stuff that matters.
Re:VIMMaster by benjaminclauss on Wednesday August 27, 2025 @01:14PM (#45042331)
These little tutorials and games are great. I played VIM Adventures.

However, one thing I really struggle with is learning when I can be doing something more efficiently. I rarely use markers, anything beyond default registers, commands, and so on.

I'm giving Neovim a try for my systems course trying to get better but I do wish these sorts of games pushed me to get better at these more advanced usage tricks.

Re:VIMMaster by soperj on Wednesday August 27, 2025 @01:54PM (#45042781)
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.

Re:VIMMaster by zeke on Wednesday August 27, 2025 @02:19PM (#45043100)
You 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.
Re:VIMMaster by dwater on Wednesday August 27, 2025 @02:30PM (#45043228)
And 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.
Re:VIMMaster by Izkata on Wednesday August 27, 2025 @05:40PM (#45045645)
I turn on relative line numbering so that y123G might be y8j and vim will show me the 8.
Re:VIMMaster by ramses0 on Wednesday August 27, 2025 @02:41PM (#45043375)
ma, 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".
Re:VIMMaster by soperj on Wednesday August 27, 2025 @04:58PM (#45045189)
and this is why i always read vim articles... i've never used registers in my life.
Re:VIMMaster by ramses0 on Wednesday August 27, 2025 @11:01PM (#45047879)
I'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.

Re:VIMMaster by asimovDev on Thursday August 28, 2025 @07:11AM (#45050754)
I 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
Re:VIMMaster by codyb on Wednesday August 27, 2025 @04:48PM (#45045030)
I created a ViM Message of the Day script that I added to my shell to give me a prompt every time I opened a new shell (Which I do constantly in ViM and Tmux since I've created leader key shortcuts in both)

https://github.com/cboppert/motd

You might have to futz with it a bit, and I think I've added some other stuff in there since then (love the toggle-light-mode script which toggles several things either to Dark or Light mode at once so I can switch environments easily, however have never gotten it to fully automate, so I have to manually type goDark or goLight depending. Humbug!)

Anyways, it's great cause it gives you one tip or command at a time, and so you can sort of slowly grow without really having to dedicate much time to it.

Re:VIMMaster by charlie-83 on Wednesday August 27, 2025 @05:36PM (#45045601)
Check out vim golf. They are fun puzzles but you also realise lots of little optimisations you can incorporate into regular use
Re:VIMMaster by j1mr10rd4n on Wednesday August 27, 2025 @06:30PM (#45046143)
> learning when I can be doing something more efficiently

hardtime.nvim[1] (or vim-hardtime[2] if you're old-school) do exactly this but within your editing session. There's an associated blog post[3] explaining the rationale behind some of the workflow choices and you can of course bring your own.

[1]: https://github.com/m4xshen/hardtime.nvim

[2]: https://github.com/takac/vim-hardtime

[3]: https://m4xshen.dev/posts/vim-command-workflow

Re:VIMMaster by JackMorgan on Wednesday August 27, 2025 @10:16PM (#45047599)
I wrote up some exercises to help build the muscle memory of advanced vim commands: https://github.com/steveshogren/10-minute-vim-exercises/blob...