I am learning new things about vim all the time. Today’s revelation was the pipe symbol (|). I had to update a function call across multiple files, here is what I was doing.
- cd to the root of the project
vimgrep functionname **to get the list of matching files.
- Now I wanted to modify the call in all files, but only after reviewing the individual call. Initially I was doing individual
cn, but given the large number of files this seemed very inefficient (I don’t want carpal tunnel syndrome!).
So, a quick search revealed the pipe/bar (|). This lets you specify multiple commands at once. With this new knowledge, I replaced step 3 above with…
:%s | w | cn
…and now I can quickly review the call before doing the modification.