Questions tagged [vimgrep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
276 views

Is it possible to populate the quickfix list with files based on criteria that are independent of the files content?

I am interested in populating the quickfix list with filenames selected according to a criteria that is independent of the files content. For example, I want to populate the quickfix only with python ...
Barzi2001's user avatar
  • 440
1 vote
1 answer
137 views

How to use alternation operator in ripgrep + vim?

I have the following in my .vimrc which (I believe) makes :grep within Vim use rg: if executable('rg') set grepprg=rg\ --no-heading\ --vimgrep\ --hidden\ --case-sensitive\ --ignore-vcs\ --glob\ '!....
Aaron Parisi's user avatar
1 vote
2 answers
177 views

How to create qf or location list from results of shell command

I often open the results of an external project-wide find | xargs grep command into a new tab like this :tabnew|read !find . -iname \*.py | xargs grep -n 'pattern' I then use gf to open the matching ...
textral's user avatar
  • 113
2 votes
1 answer
138 views

Vimgrep: select different files in quickfix list without switching window?

Let's say I have some file a asdf b asdf c and search :vimgrep /asdf/g %, and open the quickfix list :copen. Now I can navigate between the two results using j/k and jump to said result using Enter. ...
flawr's user avatar
  • 185
1 vote
1 answer
163 views

How to create key-mapping for vimgrep with dynamic values for {file} argument

Problem I am trying to create a more dynamic mapping for vimgrep. Many project directories I work in don't have consistent names for directories in which source/test code lives (ie. test vs. tst). I ...
clarkjoe's user avatar
1 vote
1 answer
194 views

How can I keep open buffers whose contents match a pattern and delete the rest?

Let's say I have three files opened in my buffer list: file1,file2 and file3. I know that if I use the command :vimgrep /pattern/ ## I'll populate the quickfix list with the files that have the ...
raylight's user avatar
  • 505
1 vote
2 answers
132 views

How to avoid getting search results from files that are in a directory that contains a folder named "xyz" in its path

I would like to exclude results of a vimgrep search pattern from the quick fix list. The exclusions should be for all files that are under a directory or parent directory called "xyz". ...
Dsp guy sam's user avatar
0 votes
1 answer
218 views

leader based shortcut to vim grep content in " register

I would like to do a vimgrep shortcut where I am able to place the contents of the register, ", as string input, something like: noremap <leader>s :vim /<something here that could ...
Dsp guy sam's user avatar
1 vote
3 answers
273 views

Function That Substitutes Across Multiple Files

I'm trying to create a function that implements the functionality outlined here: Vim search replace all files in current (project) folder My current attempt: nnoremap <C-F> :call ...
Edward Chamberlain's user avatar
1 vote
1 answer
163 views

User <cword> inside a vimgrep regex expression

Writing a map to find header under cursor for markdown link. ## heading {#foo} ... ... [click on link](#foo) <- `cursur above this foo` What I am doing: nnoremap gO :lvimgrep "\v^#+.*(#.*)&...
me_astr's user avatar
  • 153
-1 votes
1 answer
161 views

Neovim - vim-grepper shows no result

I use Vim daily and use vim-grepper (https://github.com/mhinz/vim-grepper) as my grep plugin. But since last week, it doesn't work anymore and every request I do result in... nothing found. I tried to ...
Charles Duporge's user avatar
7 votes
2 answers
859 views

Convert absolute path to one relative to another absolute one

Context I’m working on an 'omnifunc' function for Markdown editing. It’s supposed to help me link to other Markdown files while I’m typing a link – based on file content though, not file name. Suppose ...
scy's user avatar
  • 173
2 votes
1 answer
306 views

Remove full path from quickfix list when using vimgrep

I use VIM 7.4. When I want to search some text in my project, i use following command: :vimgrep /pattern/j *.c *.h Then I use :cw command to open quickfix list for getting search results. Here is my ...
wir2ozz's user avatar
  • 21
4 votes
4 answers
896 views

Find all files matching a glob pattern and add it to the quickfix window

My workflow is as following: I have a common project root where folders for projects branch of. In these branches I have markdown files with notes, snippets, various information. I mark todos for ...
JohnDoe's user avatar
  • 363
0 votes
2 answers
281 views

Given a set of patterns, list (in the quickfix window) the ocurrences in those files that contain all the patterns from a given directory

The context Given a {pattern}, I can list the ocurrences of {pattern} in all files from a {directory}, in the quickfix window with the following command :chdir {directory} :vimgrep /{pattern}/ **/* :...
gfe's user avatar
  • 245
1 vote
2 answers
206 views

How to get the number of the output of `vimgrep`

I wrote a vim-script function, which allows me to grep a keyword in my project. function! CustomGrep(...) if a:0 == 0 silent vimgrep <cword> **/*.h **/*.hpp **/*.c **/*.cpp else ...
Yves's user avatar
  • 963
1 vote
2 answers
422 views

vimscript: No match error

I'm trying to write a vim-script function, which allows me to grep the word under cursor easily in my project. function! CustomGrep() vimgrep expand("<cword>") **/*.h **/*.hpp **/*.c **/*....
Yves's user avatar
  • 963
1 vote
1 answer
220 views

Calling vimgrep from a comand

I'm trying to create a command that would accept arguments, and then call vimgrep with those arguments and display the quickfix window. I set up my command like command! -nargs=* Vsearch :call <...
SalmonKiller's user avatar
1 vote
2 answers
258 views

Put in quickfix list the files whose content does not match a pattern inside it

I would like to put in the quickfix the files not matching a pattern. That it, these files don't have any line matching the search pattern. I know that for finding files whose content match a pattern ...
aturegano's user avatar
  • 179
3 votes
1 answer
68 views

Call vimgrep from terminal

I find myself wanting to use vimgrep without having an open vim session. Then, I usually open a blank vim session (by calling vim from the terminal) and then, for instance, :vim /pattern/ *.tex. I ...
Arne's user avatar
  • 35
1 vote
1 answer
382 views

vimgrep: Search from 'tags' file location

Is there a simple way to setup a binding that will :vimgrep up until a tags file is found? I'm curious because I can do set tags=tags;/ to do a similar search to define tags, but am not quite sure ...
ThoseKind's user avatar
  • 219
5 votes
2 answers
1k views

How to load files as a quickfix window at start-up

I have a command-line tool that can print search results in a format that works with vimgrep. The example output looks like this: foo/path/lib/usdviewq/appController.py:3795:22: index = prim....
ColinKennedy's user avatar
1 vote
1 answer
51 views

Is it possible to do consecutive vimgrep searches to refine and filter results?

If I do a grep search within vim, I'll get a list of results that I can browse using :lopen. Is there a way to do a subsequent search on only these resulting files? Basically I want to do refined ...
Dianne's user avatar
  • 139
1 vote
2 answers
232 views

Exclude files from vimgrep by using bash file name expansion?

Say I have files File1.m, File2.m, and File3.m in the current directory. I want vimgrep to search all but File3.m. After reading the help on using backticks to specify files for vimgrep, I tried: :...
user36800's user avatar
  • 403
6 votes
1 answer
521 views

Changing how the quickfix list displays matches

I have the habit of leaving comments in my C source files like // @TODO or // @CHECK to quickly be able to get back to where I may have things to do. I can already match those in pretty much any ...
FlatBartender's user avatar
5 votes
1 answer
2k views

Exclude folder when searching files in working directory

I'm working in a react project and opened vim from the root folder. When I'm using :vimgrep /pattern/ ** I just can search everywhere, but I want to search everywhere except the 'node_modules' ...
ChrKahl's user avatar
  • 165
2 votes
1 answer
2k views

How to use vimgrep recursively for specific file extensions?

I'd like to search the current directory recursively for the word under cursor. Here is what I have now in my .vimrc (Note I'm on Windows): nmap <leader>f :vimgrep! <cword> **.* <bar&...
Salahuddin Ahmed's user avatar
1 vote
1 answer
222 views

Refresh `vimgrep` list?

I use vimgrep with :cnew and :cold a lot. I could be looking at a vimgrep list from several vimgrep commands ago. Is there a way to refresh the vimgrep list without typing in the corresponding ...
user36800's user avatar
  • 403
1 vote
1 answer
556 views

:lvimgrep with one match per file

Is there a way to use :lvimgrep and to limit the results to one match per file, so that each file with a match only appears once in the location list?
Andreas's user avatar
  • 347
1 vote
1 answer
1k views

my ag shortcut chokes on spaces

I got this in my .vimrc: set grepprg=grep\ -nriI\ --exclude=tags\ --exclude-dir=vendor " The Silver Searcher if executable('ag') " Use ag over grep let &grepprg = "ag --nogroup --nocolor --...
abbood's user avatar
  • 643
2 votes
1 answer
617 views

Is it possible to use vimgrep with file paths from a file?

I have a quite large directory that I frequently need to search through for specific lines. Currently I simply use the built in grep: :vim "search" **/*.cpp | cw The problem is that going through ...
pingul's user avatar
  • 235
3 votes
0 answers
402 views

Understand starstar-wildcard

I read :h starstar-wildcard, but I cannot understand some cases. (In the following examples, I am using the command :vimgrep pattern file where "pattern" is contained in the concerned files.) 1- If ...
Gradient's user avatar
  • 383
0 votes
1 answer
143 views

How can I prevent vim from changing the % register when entering non-modifiable windows?

My workflow revolves around having NerdTree opened with a quickfix at the the bottom and one file opened in a buffer. I often grep within my file only by using the % shortcut in my grep command. I ...
OlivierLi's user avatar
  • 103
2 votes
1 answer
520 views

join string and <cword> for vimgrep in command

I want to have a function that vimgrep for the word under the cursor appended to a predefined string. I have defined this command: command! -nargs=0 GJL vimgrep <cword> *.tex | copen which ...
Jan's user avatar
  • 212
3 votes
1 answer
476 views

How to always append parameters for a Ggrep command?

I'm using the Fugitive plugin. It has the :Ggrep command which is very useful for searching the repo. One annoying thing is that I have huge .map files and I want to omit them from my search. I ...
valk's user avatar
  • 143
16 votes
1 answer
5k views

How to interactively search/grep with VIM?

Is there any way to configure VIM to interactively search inside every file for an entire project? By interactive, I mean updating each keystroke. Something like Emacs counsel-git-grep, see: example ...
ideasman42's user avatar
  • 3,673
0 votes
1 answer
343 views

vimscript parse yaml header and output to mapping

My goal is to make a mapping, that depending on the value of type in the yaml header, will run a command sourcing a file named the same as the value of type. I have file containing a yaml header ...
user avatar
1 vote
3 answers
1k views

Multi file search for selected text

Using atom I can CtrlShiftf while a word is selected in order to start a multi file search for a matching string. I would like to emulate this flow as much as possible with Vim. I know I can yank ...
davegri's user avatar
  • 113
5 votes
1 answer
1k views

Calling vimgrep so that results from the current file are on top?

I would like to search for some pattern with :vimgrep in the current directory: :vimgrep /pattern/ * However this returns the results by filenames ordered alphabetically. If I run :vimgrepadd the ...
Karolis Koncevičius's user avatar