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
23 views

Autocomplete on command-line search pattern returns strange symbols of <09> and ^I

Using Neovim v0.4.3 on a just recently upgraded Linux Mint 19.3. Problem Description: After the upgrade, when typing / followed by first characters of any word below the cursor, in the buffer, and ...
0
votes
1answer
23 views

Is the pattern .\{-}\> equivalent to the move command e?

What is the appropriate way to make a pattern that matches up until the point where the move command e would have moved to? Consider this text: texttext%0s: cookie after performing /%<CR>ve the ...
1
vote
1answer
8 views

How to enable search highlight when I use `normal! n` in a function?

I've set hlsearch. When I type :normal! n, the target text is highlighted. But when I put normal! n in a function(Search) and call that function(:call Search()), the highlight doesn't take effect? ...
0
votes
2answers
55 views

How to highlight search with / and ? but not * and # vim

Is there any way to have vim highlight the search with / and ? but not when putting cursor on a word and pressing * or #? :set hlsearch and :set nohlsearch turn it on and off for both.
1
vote
1answer
27 views

Keep vim cursor position in document fixed when typing search expression

I recently upgraded vim for the first time in 5 years. Now, when I type in a search expression, the cursor in the buffer changes position with each key stroke to highlight a potential match. I want ...
0
votes
1answer
42 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 ...
0
votes
1answer
16 views

get line of first occurence of pattern in buffer

I am trying to write a function which I bind to "n" and "N" to highlight the current search pattern. That part works. I would like to detect when the cursor wraps to the first match in the buffer (...
2
votes
0answers
43 views

How to search the output of vim command line commands like `:ls`, `:browse oldfiles`

Back from emacs recently, in emacs I can list all the existing buffers in a emacs buffer, where I can do search, delete or jumping etc. In Vim, if I type :browse oldfiles, a long list may be returned ...
0
votes
0answers
23 views

Restore “search hit BOTTOM, continuing at TOP” when search navigation wraps aound end of file

I've recently switched to Neovim, and some days in, I realized that there was no search hit BOTTOM, continuing at TOP message when jumping from the last to the first search result (or vice versa), ...
2
votes
2answers
66 views

Is there an instant way of editing matching inner tags?

In Vim, using the text object i>, you can edit an inner tag, and using the built-in matchit plugin, you can even use % to jump between matching opening and closing tags. Let's say you want to ...
0
votes
1answer
31 views

I would like to find and count number of entries bigger than a certain number in front of a certain string

I would like to use vim to do the following operation in vim: I would like to determine the number of entries with avg_deg greater then "'avg_deg': 5.50" from a simple .log file as well as the average ...
0
votes
1answer
14 views

Search and replace visual block only? [duplicate]

How do I search and replace in a visual block only? '<,'>s/search/replace/ works on entire lines, not visual blocks only.
0
votes
0answers
18 views

Numpad forward slash to search without numpad?

In Vim I use the forward slash on my numpad a lot for searching. Thinking of getting a TKL keyboard I was wondering how that works without a numpad. I tried the forward slash on the regular keys, but ...
1
vote
2answers
38 views

Advance to next (multi)characters on a line

To advance to the next/previous character match on a line I can do: f <char> However, I find myself wanting to match against two characters on that line, for example, something like: f =' Is ...
0
votes
2answers
39 views

How to go to search results located in other windows?

I want to go to the search result in the right-window, identified after performing a /urllib search in the left window. Pressing n\N doesn't proceed to search results in other windows. How can I ...
0
votes
0answers
34 views

How to reload vim buffer

I built a cpp environment with YCM, EasyGrep and some other plugins. With YCM, I can jump to declaration/definition, with EasyGrep, I can grep a keyword easily. But I found something weird: Saying ...
2
votes
2answers
65 views

Search and copy the text between two markers in gvim

I want to copy strings that spans across multiple lines between two markers in a large file. In the below example file, start marker is <ROW> and end marker is </ROW>. <ROW> &...
-2
votes
2answers
56 views

How to research strightly a word in a loop?

I have text: I want to select nest and not nestlé in this text. Only the word nest! and a list : myList = ["nest"] function MyFunction() myList = ["nest"] for elem in MyList if search("...
1
vote
1answer
38 views

Search and Replace - How do you change a specific string across syntactically similar files?

I'm attempting to write a Vim macro that will allow me to replace a single variable of a single service across multiple Icinga configuration files. Services are syntactically very similar so I ...
1
vote
1answer
143 views

How can I write a filetype plugin that evaluates the first lines of the file?

I'm trying to modify my filetype.vim such that it highlights a unified diff file with diff syntax, overriding whatever syntax is normally associated with the file's extension. So far, I'm just trying ...
0
votes
2answers
50 views

Searching between two words

I have this string : content htp://ww.mySite.com/image/123kw9ykjm-065n/640/568/25452583.suite />meta property="twitter:suite and I want to get the link to add it in a list; Here is my function : ...
0
votes
1answer
27 views

Changing multiple columns of all lines that meet a search criterion

There are lots of posts about how to search and replace a single column of a file, using \%Nc syntax. I want extend this syntax to replace multiple columns in all lines that meet some criterion. For ...
1
vote
1answer
53 views

Search for Pattern “^M*”

My file contains multiple blocks looking like this some Test "^M ^M ^M "some more text I'd like to remove these passages (including the "), but can't seem to fine the right regex. EDIT: I already ...
2
votes
1answer
33 views

How to go to a line based on number of words on a line?

Just like the title says. How do I identify (and goto) a line based on its word count? For example, what if I want to go to the next line containing more than 5 words?
0
votes
1answer
89 views

search a pattern preceding cursor position, modify it and insert the modified string

I am writing a mapping to autocomplete tags Pattern: <.*?>, matches complete HTML tags only. The goal is to lookbehind and see if there exists a text like <html>. Mapping: inoremap <...
1
vote
3answers
313 views

How to highlight all occurrences of a search without moving the cursor?

How to highlight all occurrences of a search without moving the cursor? I want to highlight all occurrences of a word in the neighbourhood of the cursor without moving the cursor. Currently, if I ...
3
votes
1answer
54 views

How to search only in a text which is not folded?

I would like to use search in file with folded functions to search only in functions titles. But common vim search searches inside folding and unfolds any hidden text. Is there a way to search only in ...
0
votes
0answers
43 views

Match (Search, Letters)

I Have this function : function! Test1() let myWord = "accroche-coeur" let cont1 = "-" if match(myWord,cont1)>=0 " if myWord contains cont1 echo "Ok" else ...
2
votes
1answer
48 views

Case insensitive conservative substitution

Is there a built-in way in Vim to search for a pattern in a case-insensitive way, and substituting the occurrence conserving its case? (Something like an s/abcd/efgh that matches AbCd and replaces it ...
1
vote
1answer
43 views

Search backward for first line not matching a pattern?

Is there a way search backward from the cursor for a line that doesn't contain a pattern? For example, many of my lines match the regular expression ^ adding: \i\+. I want to find the first line ...
1
vote
2answers
41 views

How to start search `/` from a mapping?

I'm trying to do the following mapping in my vimrc: nnoremap <silent> / :call <SID>FooFunction()<CR><BAR>norm! / But when I press /, instead of running the function and then ...
1
vote
2answers
387 views

Autocomplete incremental search behaviour

Consider the following scenario Content of the buffer: I saw the water in a thermal bath. Commands issued: :set incsearch /th^R^W^R^W^R^W^R^W Result thewaterIII Question What exactly is the ...
2
votes
2answers
38 views

How to search and replace more than character and a string in vim

I know it should be easy, but somehow I don’t get it right. I've got a text with artist_id, album_id,... and want to replace them with just id. How do I do that? I tried :%s/[a-z]+_id/id/gc, but ...
2
votes
1answer
58 views

How to search & replace the word under cursor without changing position?

This question is related to Do a forward slash search but don't have vim immediately jump to the string? but is not a dup. I recently updated my Linux box (clicked on the "install updates" button ...
2
votes
2answers
1k views

Grabbing values between quotation marks

I want to create a regex that matches strings within single or double quotes in vim and that considers the fact that some strings might have escaped single quotes or double quotes. So far, I've found ...
1
vote
1answer
44 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. ...
1
vote
1answer
42 views

How to execute with call and <C-R>/ matching?

I want to count the searching pattern and here is my code: execute '%s/' <C-R>/ '/\=' . Count(submatch(0)) . '/gn' Here is my Count function: function! Count(match) if has_key(b:types, a:...
8
votes
1answer
3k views

What's the difference between `/x` and `:/x`

Assume buffer content: aa bb yy xx aa bb What's the different between /xx and :/xx?
1
vote
1answer
90 views

search highlighting only in the current buffer

I know that I can run a search in vim using /. I prefer having search highlighting turned on, but if I have a two splits with different files open, and I search for a term in one, they get highlighted ...
0
votes
1answer
55 views

Can I use feedkeys() inside of a keyloop implemented by getchar()

I implemented a fuzzy filter, which accept a list argument, open a window with a scratch buffer whose content set to the list, then waiting for use input and do filtering. Here is why I ask this ...
7
votes
6answers
2k views

How to replace a pair of brackets

I have a file, containing some lines like this: aaa bbb (ccc) ddd. Now I want to replace the pair of brackets by a pair of square brackets to make this line become aaa bbb [ccc] ddd. I think that \...
0
votes
1answer
47 views

How to break lines into a certain amount of characters?

I have a long text file (300 lines), and I would like to format it so each line is not longer than 50 characters. For example, we have: I have a really long text, I have a really long text, I have a ...
0
votes
2answers
46 views

Search for a word and if occurs, delete it and move to the end of line

I need to search for a certain word, and if it occurs, move it to the end of the line where it occured. For instance, search for "bugs". Welcome! Meta Stack Exchange is intended for bugs, features, ...
0
votes
1answer
35 views

Search for lines that do not have certain characters in a row

I have a news article which I need to edit up a bit. Basically, I need to search for all lines that do not contain characters t and h 2 or more times in a row and replace 4 letter words with character ...
3
votes
1answer
33 views

search for pattern and insert text that precedes the pattern from pattern1 to pattern2 exclusive

basically I have a bunch of lines of code that all match the format .\module.variable (), .\module.variable2 (), I want to take everything between the backslash and the space, before the parentheses ...
2
votes
2answers
122 views

vim incremental command history search

In bash you can easily search the current history entries by hitting <C-r> or <C-s>. This search feature is incremental, and once you hit return, you get a bash prompt auto-filled with the ...
1
vote
0answers
28 views

How do I remap result navigation buttons after a search?

I search with /, press enter, and go a few results down using n. I realize that I have gone a few more results down than I meant to and want to go back a few. I press m because that is next to n just ...
2
votes
1answer
113 views

Don't jump on search and replace

How do I get my cursor to not move to the last thing it replaced after a search and replace. No <C-o> or extra key presses. Is there some autocmd magic I can setup to listen on any substitute ...
2
votes
4answers
709 views

Jump back to the position I started a search

I have a small question: let's suppose I'm at the beginning of line 10 and I search a term with the command /term_to_search and then I press <Enter> to start navigating search results with n or ...
0
votes
1answer
85 views

Add a line after 1 line after match in Ex mode

I need to search for a string in a file, then I need to some text after one line following the first match. I need to perform this for a number of files in a script. I am trying to use vim ex mode ...

1
2 3 4 5
8