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
0answers
60 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 ...
2
votes
1answer
59 views

Date change question: Find and replace with wildcards?

I have a file with a bunch of dates of the form a/b/c, where a,b, and c are numbers of varying character length. However, I'd like to change every instance to read c/a/b. I'm wondering if there is a ...
4
votes
4answers
658 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 ...
83
votes
10answers
94k views

How can I clear word highlighting in the current document (e.g. such as after searching for a word)?

When you search for a word in a file with something like /console.log, all of the instances of console.log are highlighted. When you're no longer interested in these, the highlighting can be ...
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 ...
2
votes
1answer
60 views

How can I find where one word is close to another word?

If I want to find occurrences of the word 'arc', I can type / arc , with spaces around the three letters, to find basic occurrences of the word (ignoring punctuation). But suppose I want to find where ...
2
votes
0answers
189 views

Can't search for strings within hidden files with fzf's Rg command in vim

I just installed fzf for my bash terminal and the fzf.vim plugin for vim. I've placed the following code at the bottom of my .bashrc script: export FZF_DEFAULT_COMMAND='rg --files --hidden --no-ignore-...
5
votes
1answer
71 views

Vim find/replace highlighting

I'm a long time Vim user but a few months back started dabbling in Emacs. One of the things I really liked about Emacs was when doing a find/replace s/you/me it would highlight the word I was ...
0
votes
0answers
12 views

How to not jump back on mismatch with incremental search

With incremental search (incsearch), we jump to matches and they are highlighted as they are found. But if we hit a character that makes the search not match anything, we’re thrown back to where we ...
2
votes
3answers
63 views

How can I repeat the cgn sequence?

Recently I learned the awesome command cgn to repeat a change to a word. I’ve seen several answers advising its use, like this: What is the best way to re-factor a variable name in vim? and this: How ...
0
votes
3answers
29 views

Conditional search and replace using repeated macro or commands

I want to search for a keyword, and replace a word in the line that is not a search word. I thought macros may be a good way to do it, but I am open to any methods. I have something like, blah blah ...
1
vote
1answer
10 views

Passing a pattern as argument without extra escaping

so I want to pass a pattern to a command. command! -nargs=1 -buffer Vim silent exec "vim! /" . <args> . "/ ./*" | copen | redraw! But there is a problem. If I want to match /foo i would use ...
0
votes
0answers
17 views

Reverse n and N for ? and # searches (compared to / searches) [duplicate]

When I search with ? or #, I want n to move "forwards" through the buffer, and N to move backwards. This is opposite to current behaviour (where n moves in the search direction). How can I set this ...
1
vote
1answer
28 views

Searching for multiple keywords listed in the buffer

Given two buffers, where the first one has a list of keywords delimited by a new line; the second buffer with text that contains a subset of keywords from the first buffer. How do I search and ...
0
votes
1answer
30 views

global search and replace on all lines that don't begin with a backslash

I'm trying to globally enclose in {}'s all instances of +,-,= that aren't already so enclosed. But I don't want to do this for lines that are latex commands. Since my latex commands are all on ...
1
vote
1answer
21 views

How to insert text using substitute and regex?

Honestly I can't read regex for now. I have quick-fix list and I have a hunch that this can be done with regex but I don't know how. I want this: @ViewChild(MatTable) @ViewChild('text 1') @...
4
votes
2answers
2k 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 ...
7
votes
3answers
856 views

How to display in the statusline the number of matches from a search?

I've seen this question: Is there a way to count the number of occurrences of a word in a file? but most of the time I search using * or just /. It is possible to display automatically in the ...
50
votes
5answers
14k 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'...
16
votes
3answers
9k views

search for lines which contain a pattern but do not contain a second pattern

I need to search for lines which contain some word but do not contain a second word. For example, find lines that contain the word "This" but not the word "red" so that for a file containing these ...
1
vote
1answer
25 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
25 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 ...
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 ...
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? ...
1
vote
1answer
34 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
2answers
65 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.
104
votes
2answers
7k views

How do I navigate to topics in Vim's documentation?

In Vim's built-in help system, how do I… search for topics that I want help on? follow hyperlinks? browse around for related material?
16
votes
2answers
8k views

How to use Ctrl-P to interactively search file contents for all files in a project?

I tried today to perform a search on every files of a project. I use Ctrl-P and search on lines like so : But the result of the search is only on the previously opened file. Here I open only main....
0
votes
1answer
43 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
17 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
48 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 ...
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. ...
0
votes
0answers
62 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
86 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 ...
8
votes
2answers
4k views

Faster way to search for whole words

I can search for whole words like this /\<search term\> \< and \> match left and right word boundaries respectively. But how can I insert those automatically? They are awkward to type ...
0
votes
1answer
36 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
25 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
42 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
54 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 : ...
1
vote
2answers
533 views

Search query to match multiple instances on a line, only between certain delimiters?

I do a lot of programming in Ruby, and a common edit suggested by Rubocop (a linter) is to reformat an array of symbols [:foo, :bar, :baz] as a percent string: %i[foo bar baz] I'm looking for a ...
0
votes
0answers
35 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 ...
87
votes
7answers
51k views

Is there a way to count the number of occurrences of a word in a file?

Is it possible to count how many times a word or a pattern appears in a file? This is sometimes useful to find out how many times a function has been called, etc.
2
votes
2answers
70 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 ...
2
votes
1answer
149 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
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
58 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 ...
0
votes
1answer
90 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
2 3 4 5
8