Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Search multiple terms in Vim

📅 2012-May-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ search, vim ⬩ 📚 Archive


Vim has support for extended regular expressions in its search. So, it is possible to search for multiple terms at the same time. This support for alternation using extended regular expressions is not present in Vi.

The operator that is suitable for this is \|. For example, to search for either NewWidth or NewHeight in the source:


Thanks to Edward for this tip.

Note that if you have highlighting enabled, which is a very useful feature, all the matches will be highlighted with the same color. If you would like each term to be highlighted with a different color, try a plugin like multisearch.

Tried with: Vim 7.3

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧