Nice, but still wondering if I should know vim since nano is enough for me :)
A Vim Guide for Advanced Users
31–40 of 179 posts
Re: A Vim Guide for Advanced Users
#32The 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…
Why is this preferable to :%s?
It's also better if you don't actually want to replace in the whole file and there's no convenient shorthand for the range.
I very rarely use :s myself, I'm always too worry that I'm going to clobber something I didn't mean to, I prefer to search and manually repeat a substitution. s can do it with with the "c" modifier but I find that using normal edit commands is both more flexible and easier to remember.
Re: A Vim Guide for Advanced Users
#33Superb submission! I've been using vim for over a decade and I never knew about gx or gf. Thanks!
Re: A Vim Guide for Advanced Users
#34Superb submission! I've been using vim for over a decade and I never knew about gx or gf. Thanks!
I was meant to write a blog post like this since forever. Anyway, if you want really advanced stuff this[0] is definitely a way to go. As for ```gx``` since I'm using aerc as my email client, a trick I found very useful to open links using only the keyboard is to open an email then rq (reply with quote) search for the link and gx. 0: https://www.ele.uri.edu/faculty/vetter/Other-stuff/vi/009-in... Edit: add the bit ab…
Re: A Vim Guide for Advanced Users
#35Superb submission! I've been using vim for over a decade and I never knew about gx or gf. Thanks!
Related, gF will also scroll down to the line number if specified as: File.txt:45 Very handy when using a terminal from within vim and looking at compiler errors/warnings or log files etc.
Re: A Vim Guide for Advanced Users
#36The 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…
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.
Re: A Vim Guide for Advanced Users
#37Practical vim by Drew Neil is hands down the best vim learning resource out there. Nothing even comes close.
Re: A Vim Guide for Advanced Users
#38Thank you! Two things I really got from this: Capital marks. I use ma or ms and `a `s a lot, but did not know you could do global marks with mA and `A. Very useful! I've been using `` for a long time to mean "go back to the last place I was editing" but sometimes it gets overridden when navigating (I'm not super familiar with the jumplist, so maybe I need to get a better understanding) but `[ and `] are exactly what…
You should try g; and g, You'll go through the change list. I think it's what you want. I explain it in the article vim-intermediate on the same blog :)
Re: A Vim Guide for Advanced Users
#39The 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
#40The 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…
:%s/debug/dbg/c
vim will show the text which is about to be modified, and you have a prompt to confirm, skip, or quit (and some others).