Is there a way I can open vi/vim with a given word ( or regex pattern) to match so that the cursor is on the first matched word ( regex pattern) after opening. Something similar to the line no. option
vim +line_no file.txt
and I'm looking for something like
vim /regex/ file.txt
This is helpful when I don't have the line no. handy and I can avoid grep
ing the file to search it quickly
Add a + to your "something like" and you have your answer -- vim +/regex file.txt
is what you are looking for (remember to quote your regex to avoid shell from messing it up).
Check out :help starting.txt
for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With