←back to thread

VIM Master

(github.com)
378 points Fluffyrnz | 3 comments | | HN request time: 0.655s | source
Show context
benjaminclauss ◴[] No.45042331[source]
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.

replies(5): >>45042781 #>>45045030 #>>45045601 #>>45046143 #>>45047599 #
soperj ◴[] No.45042781[source]
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.

replies(3): >>45043100 #>>45043375 #>>45050754 #
1. ramses0 ◴[] No.45043375[source]
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".
replies(1): >>45045189 #
2. soperj ◴[] No.45045189[source]
and this is why i always read vim articles... i've never used registers in my life.
replies(1): >>45047879 #
3. ramses0 ◴[] No.45047879[source]
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.