Random compilation of (n)vim tricks I picked up over the years

  1. 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> | nvim and then use visual block to remove the directory information and replace it with - [ ]
  2. :argdo is pretty useful if you want to find/replace something across a bunch of files. In tandem with the -c option of vim, it becomes possible to do vim -c "argdo %s/#include <foo>/#include <bar>/g" *.cpp , skim over the results and do wqa. 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 -0 is 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 can qa! and give it another try.