A Vim Guide for Advanced Users
121–130 of 179 posts
Re: A Vim Guide for Advanced Users
#122Nice, but still wondering if I should know vim since nano is enough for me :)
Re: A Vim Guide for Advanced Users
#123The 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
#124- Find the pattern that you want to replace (the last dot is for current dir)
:grep -r 'pattern' .
- Open the quickfix window and check if matches are correct
:copen
- Find and replace the entries of the quickfix list
:cdo s/pattern/replacement/ | update
Re: A Vim Guide for Advanced Users
#125Earlier quoted context omitted.
Oh I never thought about that either. Thank you.
I rarely actually do it because f and t motions, possibly with a number, can usually handle these cases. For example, c3tA to change up to but not including the third capital A after the current position
Re: A Vim Guide for Advanced Users
#126Nice, but still wondering if I should know vim since nano is enough for me :)
I know the basics because vi ships with practically ever *nix (unlike Emacs), so it's there for when I need to edit config files, but I do 97% of my real work in something more like IntelliJ, so there just aren't big returns for getting better at vim.
Re: A Vim Guide for Advanced Users
#127Re: A Vim Guide for Advanced Users
#128Earlier quoted context omitted.
It's CTRL+X and then N to not save changes
Thanks! Gonna try to remember that combo.
Save modified buffer?
Y Yes
N No ^C CancelRe: A Vim Guide for Advanced Users
#129Earlier quoted context omitted.
My thoughts exactly about ':sort u'
The u option making it keep only unique lines, for anyone else left wondering. Personally, instead of re-learning how to do stuff with vim-sepecific commands, I just use the existing command line tool, especially since I don't do this on a daily/weekly basis (but I use sort in command line pipes at least weekly). The command is literally "sort" and for unique you just pass the -u flag, e.g. select something in Vim an…
Re: A Vim Guide for Advanced Users
#130The 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…
The g and z set of commands are pretty useful in vim.