Questions tagged [search]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
49 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 ...
2
votes
1answer
21 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: ...
2
votes
1answer
2k views

How to have forward search using Zathura PDF viewer and LaTeX-Box plugin?

I just started using Zathura to view pdfs while editing tex files. I am trying to have forward searching capability in Zathura. Using the LaTeX-Box plugin in Vim, I have added the following in my ...
0
votes
2answers
169 views

Autocomplete popup menu for search results

Autocomplete in insert mode (via <c-n>/<c-p>) is excellent, in particular the navigable popup box. I would like the same navigable popup box when I search: so, I type /, then start to type,...
1
vote
2answers
191 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 ...
0
votes
1answer
66 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 ...
2
votes
1answer
51 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.
66
votes
5answers
26k views

Vim search replace all files in current (project) folder

One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors). For instance, let'...
0
votes
1answer
46 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 ...
4
votes
1answer
61 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 ...
2
votes
1answer
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/...
0
votes
3answers
43 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 ...
1
vote
1answer
27 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! ...
7
votes
2answers
407 views

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 '...
1
vote
1answer
80 views

How to add a certain word before the names of methods in Javascript?

I am working with react. First I had a component with state I created methods and all that. Now I want to convert it into stateless component. I have add the word function before each method name. ...
4
votes
3answers
484 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 ...
1
vote
1answer
28 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 * ...
0
votes
1answer
92 views

How to get the same message and error behavior as normal `n` when calling `normal n` in function

I wrote a vimscript function that prevents the cursor from changing its location on the screen when I press n: function! s:my_n() let l:start=line("w0") let end = line("w$")...
2
votes
2answers
41 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 ...
2
votes
1answer
54 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 ...
1
vote
1answer
44 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 ...
6
votes
1answer
111 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 ...
1
vote
1answer
59 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 ...
2
votes
1answer
68 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 ...
8
votes
3answers
649 views

How can I automatically center first search result?

I want to have the very first search result centered on the screen. I know about :nnoremap n nzz mapping, but it only works for centering next matches, not the first. I thought that maybe I could use ...
1
vote
1answer
131 views

Reverse of `;` in find command

When I do something like: f G To find the next G on the line, I can press ; to find the next occurrence. However, once I've passed one, is there a way to find the previous occurrence? Likewise with ...
1
vote
1answer
33 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. ...
1
vote
1answer
109 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 ...
3
votes
0answers
27 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 ...
14
votes
5answers
2k views

Quick search, limited to a C++ function

I work on a rather large C++ project. One of the more frustrating aspects of its organization is very large functions placed inside ridiculously large files. I often want to search for any instance ...
14
votes
3answers
2k views

What's the difference between the '\zs' and '\@<=' atoms in Vim regex?

This is what I get from the documentation: \zs "starts the highlighted part" after matching the preceding regex, and \@<= "starts the highlighted part" after matching the ...
4
votes
4answers
3k views

autocompletion in command line/search

There is some way to "extend" autocomplete functionality (like that one supplied by SuperTab plugin) to be used in command line mode so I would autocomplete when searching a text with / command? ...
0
votes
0answers
273 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: ...
0
votes
3answers
161 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 ...
6
votes
3answers
4k views

How to execute command on every matching pattern, not just lines?

I know in vim I can use :global to execute commands on the matching lines. But I'm wondering if it's possible to execute those commands on every matching pattern, not just lines, consider following ...
0
votes
1answer
54 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 ...
32
votes
10answers
27k views

How to automatically turn off "hlsearch" after I'm done searching?

I love the "hlsearch" setting, but after I'm done searching, I find it obnoxious. Especially if I search for something that has a lot of matches. I know that I can turn this off with :set nohlsearch ...
1
vote
1answer
40 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 ...
0
votes
0answers
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 ...
1
vote
2answers
320 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 ...
1
vote
1answer
152 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,...
1
vote
1answer
39 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. ...
0
votes
1answer
536 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 ...
0
votes
1answer
24 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 ...
24
votes
4answers
9k views

How to show search results for all open buffers

One thing I often do (but rely on the command line to do) is searching/grepping in multiple files. Is there a way to display search results for all the open buffers? Ideally, I'd like to have a new ...
0
votes
1answer
80 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 ...
2
votes
0answers
102 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 ...
7
votes
4answers
911 views

Show exact number of matches even for large (>99) numbers

When I search for something /search-term and it shows up more than 100 times in my file, vim shows me that I'm on match x/>99 instead of x/121 etc. For smaller numbers it shows me the exact number ...
1
vote
1answer
46 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 ...
3
votes
1answer
67 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 ...

1
2 3 4 5
9