Live data from Hacker News

A Vim Guide for Advanced Users

thevaluable.dev

161–170 of 179 posts

Re: A Vim Guide for Advanced Users

#161
post #46

gf is a game changer! Great article – hard to soak up so much knowledge at once. Bookmarked.

I agree, it's a bit dense, but like somebody else was saying on this thread, I think picking one or two things from it and trying to include it in your worfklow for a limited period of time (say one week) will work better than trying to learn everything at once.

Then you can try new stuff the next week, and so on. Rinse and repeat :)

Re: A Vim Guide for Advanced Users

#162

How does gI differ from I?

the article has a tricky typo here. it says "The keystroke `I` insert text after the first non-blank characters of the line." but it should say _before_ the first non-blank, which is equivalent to _after_ the last leading blank.

Very good point. I'll fix that. Thanks!

Re: A Vim Guide for Advanced Users

#163
post #45

Earlier quoted context omitted.

Wow this looks super interesting. Thanks for sharing :)

No problem, I also wrote a blog post about Vim sessions[0]. I think it definitely counts as intermediate/advanced vim material. Great work with your article. 0: https://rmpr.xyz/Vim-Session/

Nice! I did that for managing my vim sessions:

" Save session nnoremap ss :mksession! $VIMCONFIG/sessions/ " Reload session nnoremap sl :so $VIMCONFIG/sessions/

Re: A Vim Guide for Advanced Users

#166
post #81

Vim is getting more popular. Not just within vim, but outside vim! Practically every full-featured editor has a vi or vim mode, and when they say vi, usually they also mean vim. Things that have nothing to do with vim but are inspired by vim are even sprouting up! And apparently it's OK to name something based on vim: https://groups.google.com/g/vim_use/c/EnSMrx_rGg4/m/d_nVlmLQ... Edit: In Bram's reply he mentioned t…

I used to work near a gym called “Vim Fitness”[0] in Cambridge, MA and there were endless jokes about trainers calling out: “H! J! K! L!” [0] https://vimfitness.com/

I work at a company called Vimcar which I like to describe as "like Emacscar but better." ;)

Re: A Vim Guide for Advanced Users

#168
For my daily tasks, VSCode works better than Vim. But, sometimes, I'll have to do a macro in Vim, end up staying there for a couple of days and I have to admit: using those commands, motions and macros is pretty fun. It feels like gamifying work for me, adding an extra layer of enjoyment to the frequently boring tasks.

Eventually I notice that I'm playing with Vim instead of finishing tasks, and go back to VSCode...

Re: A Vim Guide for Advanced Users

#169
post #12
post #5

The article mentions ”gn” in passing, but it doesn’t give it enough credit: this is an enormously useful motion, almost more useful on its own than the rest of the article. The thing that makes it golden is that it is a motion, and thus combined with a command, it is repeatable! So, like: 1. Search for something (either using / or *). 2. Type ”cgn” in Normal mode (i.e. change next search match) and replace what you s…

This has one huge shortcoming: when the next match is off-screen, pressing . jumps immediately to the next match and replaces it, before you had the opportunity to review whether you want that. To solve this I wrote a little plugin (that I finished as a plugin yesterday and uploaded just now): https://github.com/orlp/vim-quick-replace It requires vim-repeat (and a patched one because the current one has an issue): ht…

Can't you just press n to jump to the next match without substituting, then if you're happy to continue, press . and it'll replace it? I use n and p with cgn all the time.

Works a treat!

Re: A Vim Guide for Advanced Users

#170
post #87

The article mentions gI but that's 3 keystrokes (g, shift, i) when you can do 0i, and you probably want to know about 0 and i regardless, making the extra learning of gI unnecessary. Unfortunately this doesn't help anyone because it's not as if by deleting gI from your memory you can more easily learn something else, but perhaps it's helpful for a future guide writer or perhaps someone knows why gI is useful. Edit: T…

The number of keystrokes is an interesting number to use because it is only roughly correlated with the time it takes to press the keys. Both 2dd and 2[] are three keys, yet the latter can be typed much faster than the former as it is spread over both sides of the keyboard and it doesn’t repeat a key (so you can “roll” your fingers over the [] which is faster than double pressing the d). In the case of g-shift-I, I’d…

Of course I agree with the main point that keystrokes is not the same as fast to type, 2dd would indeed take me longer than 2[].

For me, though, shift is annoying. The duckduckgo bangs I find a pain and I don't use them (shift+1 is fairly uncomfortable a keystroke compared to one of the symbols available without shift) but a lot of people advertise it as a handy feature. Timing the shift key correctly is something I get wrong more often than other keystrokes, perhaps because it's operated by the pinky (though letters like "p" in operate and "a" in and are also pinky-operated and those work fine for me, idk). For me g-shift-i it's really 3 keys, not 2.5. I'd even go so far as to say that 0i is more like 1.5 than 2, since they're so nicely next to each other. By moving my right ring finger to the 0, my index finger almost automatically falls on the i. Conversely, the g and then shift makes me have to stretch my hand slightly (I find that less comfortable than shifting its position), or if I were to use the right shift, then that would be quite a big movement and stretching back to reach the i (though I rarely use the right shift: my natural hand position (to not have my wrists at an angle without needing to use a split/angled keyboard) has my right pinky in the position of the p rather than the semicolon).

Post reply on HN