Live data from Hacker News

A Vim Guide for Advanced Users

thevaluable.dev

61–70 of 179 posts

Re: A Vim Guide for Advanced Users

#61
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…

So I've been using vim for nearly twenty years and didn't know this. I also never touch visual mode make any advanced use of buffers or marks. I feel like some kind of caveman now.

Re: A Vim Guide for Advanced Users

#62
post #12

Earlier quoted context omitted.

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…

You can just type n, followed by ., to view the next match before changing it.

I used to do that but my brain messes up "n." for replace, "n" for skip, whereas "." for replace, "n" for skip is really easy.

Re: A Vim Guide for Advanced Users

#64
post #30

Earlier quoted context omitted.

Oh man, I knew there had to be a way to do that but I couldn't find it, so I always resorted to counting the number of characters in the match and then use cl to replace it if there was no convenient motion like some kind of barbarian.

The non-barbarian way to avoid counting characters when there's no convenient motion is visual mode. Hit v, then hit l until you've highlighted the part you want to change, then hit c to start changing it.

Oh I never thought about that either. Thank you.

Re: A Vim Guide for Advanced Users

#65
post #19

Practical vim by Drew Neil is hands down the best vim learning resource out there. Nothing even comes close.

What are the high points? Would you expect it has much to add for someone who's been using vim for closer to 3 decades than 2?

In some ways it's quite conceptual about the best way to use vim. Inside the cover there's a quote "I thought I knew vim, but practical vim has massively improved my code-wrangling productivity".

Re: A Vim Guide for Advanced Users

#68
post #8
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…

Ooh, sounds interesting. I'll have to look up the details. I currently do this after a search with / and regex (if it is a bit complicated) :%s//replace/gc

This is what I do, I use regex's so often it's easier for me to read this even if it's a little bit more typing

Re: A Vim Guide for Advanced Users

#69
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…

I was looking on how do this exact thing! Thank you! In IntelliJ I press Alt+j to add to selection then I can edit all matches. You just described how to do the same effect in Vim

Re: A Vim Guide for Advanced Users

#70
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 the household cleaner. Apparently it's similar to Ajax. That's so awesome. https://en.wikipedia.org/wiki/Vim_(cleaning_product)

Post reply on HN