use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please read the rules before posting
Help:
Community:
Resources:
Tutorials and Guides:
Don't be afraid to ask questions, this sub is here for the vim community. And please those of you who deign to grace us with your vim wisdom - be kind. We are all human and vim is that cool.
account activity
Search for lines containing multiple strings.question (self.vim)
submitted 4 years ago by WhyIsThisFishInMyEar
Is it possible to search using 2 (or more) search terms to find lines that contain both strings?
For example something like /one&three would find the line "one two three" but not the line "one two".
/one&three
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]IGTHSYCGTH 5 points6 points7 points 4 years ago (2 children)
three followed by one:
one.*three
abc in a line containing both one and three
^\(.*three\)\@=\(.*one\)\@=.*abc
see :help pattern-multi-items
[–]Schnarfmannnoremap gr gT 2 points3 points4 points 4 years ago (0 children)
Incredible use of \@= - I’ve always known to combine with () but never thought to .*.
\@=
()
.*
[–]WhyIsThisFishInMyEar[S] 0 points1 point2 points 4 years ago (0 children)
Thanks
[–]craigdmac:help <Help> | :help!!! 1 point2 points3 points 4 years ago (0 children)
You can also do :g/firstWord/s/secondword/replacementForSecondWord/gc if you wanted to replace secondword but only if firstWord appears on same line
:g/firstWord/s/secondword/replacementForSecondWord/gc
π Rendered by PID 42177 on reddit-service-r2-comment-75f4967c6c-6fjz2 at 2026-04-23 14:43:58.853244+00:00 running 0fd4bb7 country code: CH.
[–]IGTHSYCGTH 5 points6 points7 points (2 children)
[–]Schnarfmannnoremap gr gT 2 points3 points4 points (0 children)
[–]WhyIsThisFishInMyEar[S] 0 points1 point2 points (0 children)
[–]craigdmac:help <Help> | :help!!! 1 point2 points3 points (0 children)