Questions tagged [search]

For questions about searching for text with / or search().

For find/replace operations, use tag [substitute] instead.

487 questions
64
votes
7 answers

How to show only matching lines?

Is there a way to hide all lines that did not match, while going through the list of result lines? In a long file, I would like to search for a pattern that will match roughly 200 lines or so. The matched lines are in random places in the file. When…
Volker Siegel
  • 2,157
  • 2
  • 18
  • 21
31
votes
3 answers

How can I perform a search when vim displays content using "more" pager?

I want to see the value of a variable, so I run the command :let Vim displays the results of this command using the --more-- pager. How can I search this for a phrase, e.g. html? I've looked the man page for the more pager which says +/ is used…
the_velour_fog
  • 3,335
  • 3
  • 22
  • 40
27
votes
3 answers

Is there search and replace history in Vim?

We can retrieve search and replace history on IDEs and text editors. Likewise is there a search history or a way to retrieve previously searched expression in Vim?
vusan
  • 381
  • 5
  • 9
22
votes
2 answers

Ignoring diacritics/accents when searching

Is there a way to instruct Vim that I want to ignore diacritics/accents when searching? For example, I would like to be able to search for kočička by entering /kocicka The ignorecase and smartcase options are very useful, but they do not seem to…
s3rvac
  • 549
  • 3
  • 10
22
votes
2 answers

What is the reverse of the 'go to next' command

If I want to go to the next , on the line then I type t,. If I wanted to go to the previous , I could use /n, enter, N but this is a bit of a fiddle. What is the best way to go to reverse the t command and go to the previous ,?
rwolst
  • 405
  • 1
  • 3
  • 5
19
votes
3 answers

search for lines which contain a pattern but do not contain a second pattern

I need to search for lines which contain some word but do not contain a second word. For example, find lines that contain the word "This" but not the word "red" so that for a file containing these lines This is a blue coat This is a red coat This…
Leo Simon
  • 715
  • 1
  • 5
  • 11
15
votes
3 answers

Jump to next occurrence of the word I just changed

If I have the following: function foo(bar) { return bar + 1; } And I use cw to change the first bar to baz, how do I jump to the next matching bar, so that I can use . to make the same change? I can't use *, because that searches for the…
Roger Lipscombe
  • 335
  • 3
  • 9
13
votes
7 answers

How to search for pattern in certain syntax regions?

I am using vim to edit latex documents. Often, I will want to change the name of a variable to something else. However, it's a little annoying to have to wade through irrelevant matches when I search for the variable name. I would like to search…
Rob F.
  • 133
  • 5
12
votes
2 answers

Faster way to search for whole words

I can search for whole words like this /\ \< and \> match left and right word boundaries respectively. But how can I insert those automatically? They are awkward to type out.
minseong
  • 2,313
  • 1
  • 19
  • 38
10
votes
2 answers

case-sensitive * with ignorecase on

I like the behavior of the 'smartcase' option, which lets searches I type in by hand be case-insensitive by default, case-sensitive when there are any capital letters. I also like the behavior of the 'noignorecase' option, which lets searches…
Daniel Wagner
  • 225
  • 1
  • 6
10
votes
2 answers

Stay at matching search result after escape

For years I unknowingly used some, shall we say, deviant distribution of vim that would stay at the location of the highlighted search result after hitting in the middle of a search instead of jumping back to the original position. I've tried…
Mahmoud Al-Qudsi
  • 296
  • 1
  • 10
8
votes
2 answers

Searching for a phrase in hard-wrapped text

When searching for a phrase in hard-wrapped text, one wants newlines to be treated as spaces. Can one have that happen? Saying /the\_sphrase\_sI\_sseek is a bit awkward.
Toothrot
  • 3,129
  • 13
  • 27
8
votes
2 answers

gvim search query for mixed AND & OR conditions

Hi I want to search text inside gvim with the following criteria a&b&(c|d). I know for a&b it is /.*a\&.*b and for c|d it is /c\|d but combining these two doesnt work. what can be the exact command ? edit: I tried .*a\&.*b\&.*(c\|d), but it is…
7
votes
2 answers

Do a forward slash search but don't have vim immediately jump to the string?

When I do a /someStringtoFind in vim it immediately jumps to the closest matched string. Almost always this is what I want it to do. Sometimes though, I want to be able to enter a string to find and not have my cursor move while I am typing the…
red888
  • 193
  • 1
  • 5
6
votes
3 answers

search line which contains forward slashes

I have a following line in one script: cp "$uploaddir"/"$file" "$cvsdir"/"$device" I would like to search if this exact line is present elsewhere in the script. Usually I would do yy and then /Ctrlr0. However, this time the line contains forward…
Martin
  • 945
  • 1
  • 9
  • 18
1
2 3 4 5 6