Questions tagged [search]

For questions about searching for text with / or search(). For find/replace operations, use tag [substitute] instead.

Filter by
Sorted by
Tagged with
6 votes
3 answers
860 views

How do I search the contents of registers?

I have a bad habit of deleting some text a, heading off to another section of the document to paste it, and finding something else along the way that I need to delete. When I get to my final ...
user avatar
  • 249
0 votes
0 answers
10 views

Excluding a tag in search is hiding the watched tag panel - Can I always show it [migrated]

I'm trying to exclude neovim questions from vi.stackexchange.com If I do a search and save that URL the watched tags panel disappears. Is there any way to always show watched tags when executing a ...
user avatar
  • 316
1 vote
2 answers
27 views

How to find/highlight a word in the current line only

As title. The current problem is that my window is scrolled to the first/next(?) global occurrence. But I just want it to move my cursor to the local one, i.e. the current line, if any.
user avatar
  • 751
0 votes
1 answer
30 views

how to find the all the lines where they are the same like A(A)(A), B(B)(B), Z(Z)(Z)?

For example: sfdAAAzsd sdfBBBadf sd1ZZZsdf Hightlighted: sfd"AAA"zsd sdf"BBB"adf sd1"ZZZ"sdf all letters will be searched only
user avatar
1 vote
1 answer
31 views

"non-greedy" [<any chars>](word) regexp problem

consider this sentence (a line in a text file): mi chiamo [Giorgio Robino](person) ed abito in [corso Magenta 35/4 a Genova](address) I want to search (select/extract) the pattern <any chars> ...
user avatar
2 votes
1 answer
39 views

How to select a regexp group in vim?

I want to select/visualize a regexp GROUP in a vim regexp expression in vim. By example I would like to highlight (search) a span of characters inside square brackets, having this line: bla bla bla [...
user avatar
0 votes
1 answer
33 views

Can't read my highlighted searches

In this display, what does the "xxx" mean? :hi Search Search xxx term=reverse ctermbg=11 guibg=Yellow On my display (cygwin/xterm), Search displays as black on black. If I do this, ...
user avatar
0 votes
0 answers
16 views

How to use advanced Regex features without too many syntax cluster

I have a bunch of typescript classes in a single file, each of them has an _update function. I want to go to _update function of a class Player. How would I do that? class Player { _update() {} } ...
user avatar
  • 145
1 vote
1 answer
18 views

Trim tabs at the end of a search query

When searching in vim and mostly in netrw I add a tab before hitting enter; muscle memory from other places. /file^I How do I make it so that a tab at the end of a search query is trimmed ...
user avatar
  • 113
0 votes
1 answer
89 views

VIM search and replace regex - how to keep the search string intact and adding to it?

I'd like to learn how to search and replace in VIM - keeping the search string intact and adding to it. Take this as a simple example. See image below. I copied a simple python script written for ...
user avatar
0 votes
2 answers
58 views

How can I display a minimap with search results?

I have a big sheet of data that I constantly input more into. It gets to a point that is hard to use, especially when I do a search of a certain topic. I am having tough time managing the data of the ...
user avatar
3 votes
3 answers
778 views

Find and replace with incrementing numbers

I have several lines that look like the following: "Timestamp": 200, "Timestamp": 1200, "Timestamp": 3100, I want to replace all the numbers, starting at 10 and ...
user avatar
  • 31
1 vote
1 answer
81 views

Advance to next non-blank line only if current line is not blank

I want to tell a command or mapping to advance to the next non-blank line before executing - but to do this only if the current line is not blank. Ultimately, I intend to apply this to a command to ...
user avatar
  • 211
3 votes
1 answer
57 views

Capitalizing a backreference in a search (NOT a substitute)

I am looking for a way to match any line in a csv file that contains an identifier (e.g. OfficeLocation) and then, later on, the same identifier in all caps. A line to be matched might look like: ...
user avatar
1 vote
2 answers
246 views

Delete a line if it contains N occurrences

Is there a way to do a search and replace where it searches for if a line contains 4 pipes ( | ) anywhere in the line it will delete it? I'm working with a big csv file and some lines have 4 pipes and ...
user avatar
2 votes
1 answer
55 views

Prevent jumping when pattern matching

Is there a way to prevent cursor to search forward when using the * or /? I just want to highlight the word I am on & others, but not move to forward nor backward.
user avatar
  • 295
4 votes
1 answer
182 views

Search and Replace on odd/even numbered lines using g

I was looking for ways to search and replace on even/odd numbered lines in vim and I came across some solution on google groups https://groups.google.com/g/comp.editors/c/xk9DMoszgq4. To search and ...
user avatar
2 votes
1 answer
26 views

Advance from currrent cursor position to next line not containing one of several expressions

In vim, is there a way to advance from the current line or cursor position to the next line that doesn't contain one of several regular expressions? For example, I can use /RegExp/<CR> or :g/...
user avatar
0 votes
3 answers
54 views

List/navigate specific syntax elements in a file?

I would like to jump through specific syntax elements in a file. For example, quickly navigate to the next string element. In a .vim file strings are defined as vimString syntax elements. For ...
user avatar
1 vote
1 answer
34 views

Jump to pattern without overriding search

I'm trying to implement a mapping for making the vim cursor jump to a pre-defined search pattern without overriding the current search, but it is falling short in multiple ways: function! ...
user avatar
1 vote
1 answer
39 views

Why is asterisk not highlighting repeated occurences of a character?

I am using the latest version of Gvim on Windows 10. When I type / and some expression, for example /a, I see all matches in the document highlighted. The documentation says that the asterisk symbol * ...
user avatar
1 vote
1 answer
82 views

Vim search quantifier "\?" failing on backward search

I have the text in the file tmp.txt below with fileformat=unix. In normal mode, if I issue the backward search command ?da\?ta<CR>, the many occurrences of data are not found. If I then search ...
user avatar
1 vote
1 answer
103 views

argdo vs bufdo for project-wide search and replace in specific folders

I have the following structure: myproject ----src file1.cpp, ..., file10.cpp ----include incl1.h, ..., incl10.h ----data data1.txt, ..., data10.txt I would like to ...
user avatar
  • 165
2 votes
2 answers
53 views

Search from vim function

I am trying to use a vim function to search whether :noh has been set or not This is similar to question found here except that question does not take :noh into account One way to search from a ...
user avatar
2 votes
1 answer
68 views

Increment numbers found in search results, using search result number as an iterator

Suppose I have a file and littered throughout are a bunch of placeholder strings for images, they all have img1.gif at present. Is there a way to search for that string and increment the number each ...
user avatar
  • 217
0 votes
1 answer
84 views

Make 'cabbrev' work from command-line but not search prompt?

I am using NeoVim, and I automatically define an abbreviation for the string W every time the commandline mode starts. However, it seems that commandline mode includes the search modes as well. I do ...
user avatar
  • 121
2 votes
1 answer
86 views

How to quickly search for today's date in a file?

Question How does one effectively find today's date in a file? The format of the date is given by GNU's date(1)'s command as: $ date '+%a %d-%m-%Y' Mon 16-08-2021 What I already tried This is how I ...
user avatar
  • 567
1 vote
1 answer
38 views

Have to hit "Enter" after searching or I lose the pattern

If I am searching for a word inside a file, if I do not hit ENTER after the search pattern, my vi loses the current match and jumps back to where it was. I have set hlsearch set incsearch in .vimrc. ...
user avatar
1 vote
1 answer
216 views

How do I delete until (and including) the 2nd occurrence of some character?

Here's an example: console.log("basename of"path.basename(__filename)) console.log(path.dirname(__filename)) With my cursor on path in the first line, I've tried: dt2) but then my cursor ...
user avatar
  • 751
3 votes
0 answers
28 views

is it possible to get incremental and hl search when using "q/" search window mode

I've been using the "q/" mode for all my searches recently because it allows quick and ease of access to previous searches, but it lacks the ability to perform incremental searches and ...
user avatar
0 votes
2 answers
136 views

Something like :g/re/p - but only print the matches instead of whole lines?

Say we have the following code: Lorem ipsum. <input name="test1"> <input name="test2"> Lorem ipsum some long text possibly so long you lose your overview. <input ...
user avatar
  • 123
0 votes
0 answers
663 views

Search throws E363: pattern uses more memory than 'maxmempattern'

I ran a /.*stem\&.*sun in vim terminal. It prompted this error without throwing me any search result. E363: pattern uses more memory than 'maxmempattern' E385: ...
user avatar
0 votes
3 answers
378 views

search and replace in whole directory recursively

I have many entities in my java project like this: public class MyCar { // The brand of the car private String brand; // The time owner bought it private Date obtainTime; // The price in dollar ...
user avatar
6 votes
1 answer
265 views

Matching any Unicode whitespace

I'd like to match in Vim any whitespace character, not only normal space (U+0020) and tab (U+0009) with \s, and the other ASCII ones like form feed (U+000C) with [[:space:]], but any Unicode ...
user avatar
  • 161
0 votes
1 answer
63 views

movement similar to "f" but you can specify more than one character as search criteria

Say we got this sentence: pafpaf apfa fpa i apa panda pafas af I would like to quickly move the cursor from the start of the line to the beginning of the word panda. I could do 6fp, but what takes ...
user avatar
0 votes
1 answer
141 views

Select buffer from list of buffers filtered by a partial name match?

Let's say I entered a folder with many files and I opened them with vim *. I know that if I want to list all the files inside the buffer I can use the command :ls, and then I can navigate those files ...
user avatar
  • 375
1 vote
1 answer
56 views

Iterate through functions calls in various files

I can jump to a function definition thanks to :tjump. Or I can search for a function call in a file with / but is there a way to iterate through function calls across various files ? If the solution ...
user avatar
  • 197
0 votes
0 answers
20 views

Map a key in "search mode" [duplicate]

"Search mode" is not a true mode, but is it possible to create mappings that only apply while typing a search after / or ?? I am wondering how one would go about mapping <C-f> to start ...
user avatar
  • 255
1 vote
2 answers
492 views

How to match all C code comments in a file?

I want to match (search) all C code comments in a file in e.g. enum { foo, /* Foo is so cool, why can't we all be more like foo? */ bar, /* but bar is mysterious and ...
user avatar
1 vote
1 answer
297 views

Use vi to replace everything between two known strings on multiple lines

I need to replace the first number that comes after AAA, with 0.05 So this: AAA,1.25,2020-08-30 BB,0.1,2020-08-30 CCC,1.6,2020-08-30 DDDD,1.5,2020-08-31 EE,1.75,2020-08-31 FFF,0.05,2020-08-31 AAA,0.25,...
user avatar
  • 113
1 vote
1 answer
113 views

Search multiple buffers without replacing

Opening all 49 files in my working folder in separate buffers, I wanted to see if there were any em dashes. I typed :bufdo /— and vim immediately went to work, processing a page of buffers at a time. ...
user avatar
0 votes
1 answer
730 views

Delete word highlighted by search

I have hlsearch activated. Sometimes I search for terms I want to correct or delete via / and then selecting for the individual instance via n. Is there a command to delete the current word on which ...
user avatar
  • 103
0 votes
1 answer
31 views

how to make vim looks for and display only files with .c or .h extension when displaying results of :find command

How can I make vim :find only files with .c or .h extensions? For example, I am interested in finding .c files starting with tsv so I would run :find tsv*. This gives too many results; how do I make ...
user avatar
0 votes
1 answer
153 views

How can I search only actual differences in vimdiff?

Basically I need to search only in areas marked red, not pink (in the default color scheme). All I can find is how to search the unfolded areas. This is not very useful to me. I have long lines which ...
user avatar
2 votes
0 answers
227 views

How to fuzzy search a git repository for content that once existed?

I love fzf.vim for file content searching within vim. But how could I use that to search for content that was once in a git repository's files? This stackoverflow question has basically two ...
user avatar
4 votes
3 answers
529 views

What does the 'z' flag for search() do?

I was looking at the documentation for search() (:help search()). I noticed that there is a "z" flag: 'z'    start searching at the cursor column instead of zero When the 'z' flag is not ...
user avatar
  • 811
1 vote
1 answer
48 views

Multi-line python comment search and replace

I have a python code with several multi-line comments like this: def hello: ''' some comment some more text some mooore text ''' def ciaoo: ''' some comment some ...
user avatar
3 votes
2 answers
174 views

Backward search in current line with search() and z option

I am trying to write a couple of simple functions to find the next and previous links in Vimwiki and move to them. Links in Vimwiki are indicated with the syntax [[link to something]]. Since I only ...
user avatar
  • 255
0 votes
1 answer
96 views

Multiline search and replace with quickfix list and :cdo

I'm working on applying doctrine/coding-standard on doctrine/orm, and I would like to work smarter. I would like to search occurences of /** * @Id * @Column(type="integer") ...
user avatar
  • 143
0 votes
1 answer
49 views

Determine if there is a matching character on the current line past the cursor

I am trying to make a mapping that performs what f would normally do if there is a character match on the line, and to do something else if no such character exists. For example, suppose if I had the ...
user avatar
  • 3

1
2 3 4 5
9