Random compilation of (n)vim tricks I picked up over the years
- You can pipe input to vim. If you want to make a checklist of all the files in a directory, you can do
ls -alh <dir> | nvimand then use visual block to remove the directory information and replace it with- [ ] :argdois pretty useful if you want to find/replace something across a bunch of files. In tandem with the-coption of vim, it becomes possible to dovim -c "argdo %s/#include <foo>/#include <bar>/g" *.cpp, skim over the results and dowqa. If you have subdirectories or a big project and only want to change files where the expression actually exists, use with ripgrep/xargs:rg "<expr1>" -l -0 | xargs -0 vim -c "argdo %s/<expr1>/<expr2>/g(the-0is in case you have files with spaces in them, it uses the null char instead of newline to separate results) I find this better than using find with sed because I have more feedback, and if things don’t look good, I canqa!and give it another try.