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…
A Vim Guide for Advanced Users
61–70 of 179 posts
Re: A Vim Guide for Advanced Users
#62Earlier 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.
Re: A Vim Guide for Advanced Users
#63Is there a good way by default to wrap a visual selection in braces/parens/brackets?
Re: A Vim Guide for Advanced Users
#64Earlier 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.
Re: A Vim Guide for Advanced Users
#65Practical 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?
Re: A Vim Guide for Advanced Users
#66Re: A Vim Guide for Advanced Users
#67Re: A Vim Guide for Advanced Users
#68The 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
Re: A Vim Guide for Advanced Users
#69The 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…
Re: A Vim Guide for Advanced Users
#70Things 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)