Questions tagged [vimgrep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
22 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 ...
1
vote
1answer
82 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 ...
1
vote
2answers
20 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". ...
0
votes
1answer
30 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 ...
1
vote
3answers
149 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 ...
1
vote
1answer
30 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^#+.*(#.*)&...
-1
votes
1answer
27 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 ...
6
votes
2answers
148 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 ...
0
votes
0answers
36 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 ...
2
votes
3answers
273 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 ...
0
votes
2answers
74 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}/ **/* :...
1
vote
2answers
100 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 ...
1
vote
2answers
173 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 **/*....
1
vote
1answer
77 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 <...
1
vote
2answers
124 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 ...
3
votes
1answer
56 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 ...
0
votes
1answer
119 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 ...
5
votes
2answers
505 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....
1
vote
1answer
41 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 ...
1
vote
2answers
135 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: :...
5
votes
1answer
220 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 ...
2
votes
1answer
1k 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' ...
1
vote
1answer
933 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&...
1
vote
1answer
148 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 ...
1
vote
1answer
377 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?
0
votes
1answer
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 --...
1
vote
1answer
357 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 ...
3
votes
0answers
348 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 ...
0
votes
1answer
118 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 ...
1
vote
1answer
440 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 ...
3
votes
1answer
458 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 ...
14
votes
1answer
4k 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 ...
0
votes
1answer
193 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 ...
1
vote
3answers
823 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 ...
4
votes
1answer
956 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 ...