Questions tagged [search]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
64 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
51 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
51 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
87 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 ...
5
votes
0answers
58 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
31 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
35 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
19 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
290 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
115 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
18 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
448 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
21 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
50 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
57 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 ...
3
votes
3answers
404 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
42 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
41 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
41 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
36 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
110 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
21 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
25 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
59 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
47 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
113 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
33 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
68 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
241 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
517 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
55 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
77 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
62 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
votes
1answer
102 views

Enter insert mode after search?

So you're in Normal mode, then you press f followed by a character, then vim takes you to the next occurrence of that character. When you land on that character you are in Normal mode. My question is ...
-1
votes
1answer
277 views

Regex for any character that is not alphanumeric, whitespace, or a doublequote

I expect this to select all non-alphanumeric characters: [^\w] Instead it selects all non-w's. This is the regex I would use in JavaScript, Python etc.: [^\w\s"] How can I write this so that it'...
1
vote
1answer
165 views

Replace a character multiple times but within pattern

I am creating a yml file out of some variables. I have like 80 lines and they all have the pattern: my-first-command-line-var: {{ my-first-command-line-var }}, my-second-cli-var: {{ {{ my-second-cli-...
1
vote
2answers
89 views

How to remove spaces between parenthesis?

I have a text that looks like this " original call minpac#add('morhetz / gruvbox') " desired call minpac#add('morhetz/gruvbox') How can I limit vim pattern search within parentheses? I ...
0
votes
1answer
33 views

How to search/replace without appending search history?

In a BufWritePre to remove trailing spaces, my function uses a search/replace for \s\+$ over the current buffer. So after saving any buffer, this weird entry \s\+$ shows up in my search history. Is ...
1
vote
0answers
45 views

How to repeat `f <char>` in opposite direction when using `,` as the map leader?

I have set mapleader="," in my ~/.vimrc. How can I continue to repeat f <char> in the opposite direction, when using , as the map leader? Is it possible to remap , in the context of f &...
0
votes
3answers
58 views

Is it possible to exchange search patterns in vim?

Is there a way, built-in or with a plugin, that I can swap any number of two different patterns on an arbitrary range using a regex? Maybe something :s-style like :{range}exchange/{pattern-1}/{pattern-...
3
votes
1answer
94 views

open file with a particular regex search

Can one associate a regex query with a particular file, so that whenever that file is opened, the query (e.g., /text) is run, causing all instances of text to be highlighted? I considered using ...
1
vote
2answers
174 views

Trying to undestand why using \zs in regex is not working as I expect

Consider the following test String: County,Age,Age_group,Gender,Jurisdiction,Travel_related,Origin,EDvisit,Hospitalized,Died,Case_,Contact,Case1,EventDate,ChartDate,ObjectId If use the following ...
1
vote
1answer
51 views

Case-sensitive search with `smartcase` set

I have set smartcase in my init.vim so searching with /lowercase is case-insensitive, which is usually what I want. However, I sometimes want to do a case-sensitive search where my target is all ...
2
votes
1answer
48 views

Finding where one word is close to another word: parametrized command in vimrc

I asked this question, about how to find where one word is close to another word, and Quasimodo gave the very fine answer: /\vaid(\W+\w+){,3}\W+country Now I want to parametrize this command into ...

1
2 3 4 5
9