I want to find a line that has both ‘foo’ and ‘bar’ in this order but not necessarily next to each other.
I tried the following and it didn’t work:
/foo.*bar
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use:
The ‘magic’ setting determines how VIM treats special characters in regular expressions. When it’s off VIM treats all chars literally, meaning that the expression you wrote
foo.*barwill actually search for that string. However, when ‘magic’ is on then special regex chars get their special meaning and it works more like you expect. It is recommended to always use:set magicunless dealing with really old Vi scripts, so just add it to your vimrc and you’ll be set.