Questions tagged [search]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
25 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
41 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! ...
1
vote
1answer
27 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
34 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
49 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
40 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
52 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
36 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
62 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
32 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
92 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
53 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
153 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
138 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
94 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
40 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
45 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
38 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
306 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
139 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
24 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
491 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 ...
0
votes
1answer
67 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
81 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
476 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
45 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
59 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
44 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
39 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
147 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
27 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
28 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
64 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
20 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
48 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
49 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
190 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 ...
2
votes
1answer
36 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.)
0
votes
0answers
43 views

How to get information about search results from / or ? (the contents of @/)

In normal mode with default mappings, suppose I type /[,_@]. This then causes all matches of that pattern to be highlighted. Is there some way to examine the results of this search? I am specifically ...
1
vote
1answer
72 views

Show all instances of a certain string

I use * and # for quick and basic typo checking. If I type AVeryLongVariableName, I can put my cursor on the word, press * and see all the other places that word is used. I know I spelled it correctly....
5
votes
3answers
247 views

Recover whole search pattern for substitute command

Sometimes I type a long substitute command /%s/foo/bar.../ and while I am typing it or only after hiting enter I notice that I have mistakenly used a the search key (/) instead of the ex-command key (...
2
votes
2answers
730 views

Regular expression for searching IP addresses

I opened up a document in vim and I want to search the document for IP addresses. So I used this command /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3} But this pattern doesn't seem to return any of ...
0
votes
2answers
56 views

Bind a specific search to a map in normal mode

Specifically, I'm looking to bind the search /\(<<<<\|====\|>>>>\)/ (i.e. "find the next git merge boundary"). Ideally to <C-/> or <A-/>, but that part I'...
2
votes
1answer
80 views

Search and yank in visual line mode with execute normal

I have this in a buffer: aaa bbb ccc ddd eee with the cursor on the first line. I do :execute 'normal! jV/ddd\<CR>y' which I expect should result in the middle three lines yanked. But what ...
0
votes
2answers
77 views

Find the specific line with character in specific position

Finding the line with a specific character before the last character. Suppose, I have the following string 1. addar_ctrl1,1,2,0,0,1 2. addar_ctrl2,3,2,0,1,0 3. addar_ctrl3,4,8,0,0,0 4. addar_ctrl4,2,6,...

1
2 3 4 5
9