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.

  1. cd to the root of the project
  2. vimgrep functionname ** to get the list of matching files.
  3. Now I wanted to modify the call in all files, but only after reviewing the individual call. Initially I was doing individual %s followed by w and 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.

Back to blog...