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
2answers
37 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 ...
3
votes
3answers
245 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 ...
1
vote
1answer
62 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 ...
2
votes
1answer
29 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: ...
1
vote
2answers
196 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 ...
2
votes
1answer
53 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.
4
votes
1answer
86 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
44 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
29 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! ...
1
vote
1answer
30 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 * ...
1
vote
1answer
50 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 ...
1
vote
1answer
64 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
2answers
44 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
57 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 ...
0
votes
1answer
56 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
71 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 ...
1
vote
1answer
34 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
125 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 ...
0
votes
1answer
67 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 ...
0
votes
0answers
365 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
205 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
1answer
137 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 ...
0
votes
1answer
47 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 ...
0
votes
1answer
65 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 ...
1
vote
1answer
43 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
336 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
164 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
51 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
582 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
25 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 ...
0
votes
1answer
107 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
134 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 ...
4
votes
3answers
495 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
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
83 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 ...
0
votes
1answer
57 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") ...
0
votes
1answer
44 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 ...
0
votes
2answers
186 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,...
3
votes
1answer
31 views

Replacing both upper case and lowercase findings [duplicate]

I often find myself running the following commands in sequence when wanting to replace both the lower case and title case instances of a given word, while retaining its original case. :'<,'>s/...
0
votes
0answers
21 views

How to point the cursor to result when search by 'let @/ = '?

To reproduce this problem: Open a new vim window, input "abc", leave cursor at the end of line set hlsearch let @/ = "abc" The cursor doesn't point to the beginning of "abc&...
0
votes
0answers
29 views

behavior of control characters has changed in ubuntu 20.04

Before upgrading to ubuntu 20.04, the line g/;/s//CTRL V CTRL M/ would replace the ; with a new line. Now, in ubuntu 20.04 this string translates to :g/;/s//^[[27;5;109~ which obviously doesn't have ...
2
votes
1answer
65 views

Is it possible to detect a highlighted search match with synIDattr() or similar?

When I have hlsearch on and my cursor is somewhere in a highlighted search match, is it possible to detect the search highlight hl-Search with synIDattr() or a similar function? As far as I can tell ...
0
votes
1answer
22 views

possible to search two form of hex string in one time?

Some text file contains lots of hex strings, a same string presents multiple times in two formats like: 00000000 aa bb cc 25 41 f3 d9 ed 58 5c ed a0 3c 61 60 ce ...%A...X..<a`. and ...
0
votes
1answer
49 views

Search for a pattern, copy the line with the matching pattern, copy the next 2 lines, output the results into a new file

I have a file with data that goes like this. Engine1 Temp:10 Humidity:23 Engine1 Temp:13 Humidity:21 Engine2 Temp:10 Humidity:23 This pattern repeats throughout the file. I want to do the following ...
3
votes
1answer
50 views

Skip to next batch of search results (or find next non-match)?

So you search /needle, and end up trapped in a haystack of result lines. Is there a quick way to skip to the first non-matching line (and then the next batch of results)? E.g. I'm viewing the results ...
0
votes
1answer
281 views

Searching a log file using vi or view

When I open a log file in vi or view and I need to search for a word, the first thing I do is to press G to get to the bottom. Then I'll start a search using a / followed by whatever word I'm looking ...
3
votes
1answer
47 views

Delete up everything until searched term, including searched term

If the cursor is at t in the quick brown fox and we type d/brown, we delete the quick . Is there a way to extend this such that the searched term is deleted too? (Such that only fox remains.)

1
2 3 4 5
9