Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes

Prevent "Press ENTER or type command to continue" prompt after external command executes

If what you're looking for is a way to automate the sequence of commands (:silent grep and redraw!), then consider creating a new user-defined command for that operation. (In fact, Vim documentation ...
filbranden's user avatar
  • 29k
3 votes
Accepted

Accept hyphen when using `<C-R><C-W>`

A straightforward (if not exactly elegant) way to do this is just to temporarily set iskeyword to include the hyphen: nnoremap <silent> K :let s:old_iskeyword = &l:iskeyword<CR> \:...
Rich's user avatar
  • 32.1k
2 votes

Highlight results of :grep while in quickfix window

Option 1 Hack A hack... you could get the title of the quickfix window, and then strip off the parts that arent the search term: let pattern = getqflist({'title' : 0}).title let pattern = ...
run_the_race's user avatar
2 votes
Accepted

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

Simpler is function! CustomReplace(target, newWord) call CustomGrep(a:target) cdo execute 's/'.a:target.'/'.a:newWord.'/gc' endfunction Or with cfdo and %s, function! CustomReplace(target, ...
D. Ben Knoble's user avatar
  • 26.4k
2 votes

Find the specific line with character in specific position

This is the one situation where using an external tool such as awk can help, particularly if you're trying to match something on a column in the middle (not close to the start or end), or when the ...
filbranden's user avatar
  • 29k
2 votes

Find the specific line with character in specific position

Use a negated :global, e.g.: :v/,1,[^,]*$/d
Thor's user avatar
  • 121
2 votes
Accepted

How to use read instead of execute in a function?

You still need the execute, in order to interpolate the contents of the result Vimscript variable into the shell command: execute 'read !grep "'.result.'" file' Note that now this is a ...
filbranden's user avatar
  • 29k
2 votes
Accepted

How to use alternation operator in ripgrep + vim?

I would not escape neither the parenthesis and I would add quotes: grep "(const\|let) render" When using grepprg Vim pass the arguments to the program mostly unchanged. The only exception ...
Vivian De Smedt's user avatar
1 vote
Accepted

How can I use Regex in helpgrep?

You can use regexps in :helpgrep, you only need to provide a valid regular expression. Your 'word1' & 'word4' does not do what you describe. To match both "word1" and "word4" ...
Friedrich's user avatar
  • 2,125
1 vote

How to grep only the contents of the current file?

I would do: nnoremap K :grep! "\b<C-R><C-W>\b" %<CR>:cw<CR><ENTER> Remark: grep is looking into the corresponding file. If your buffer is not saved on disk the ...
Vivian De Smedt's user avatar
1 vote

How can use :grep with range in neovim with ripgrep as external grep program?

Vim/Neovim internal :vimgrep works for me. :vimgrep /^\%V\s\{8}\a\+/ % All results are places in quickfix list, grep search results respects the given visual range provided. Cheers
avimehenwal's user avatar
1 vote

grep in my specific dictionary

You can send the Grep to a split terminal buffer after closing the buffer from the previous Grep (if any). :sil!bd --color|ter grep --color -i word dictfile grep --color is required to force Grep to ...
Quasímodo's user avatar
  • 2,466
1 vote

Neovim - vim-grepper shows no result

After some research, updatin my neovim form version 0.1.7 to 0.4.4 fixed my problem. I don't really know how that fixed the problem thought
Charles Duporge's user avatar
1 vote

Prevent "Press ENTER or type command to continue" prompt after external command executes

Well, you need to do a redraw...per :h :!cmd... This requires a hit-enter prompt, so that you can read any messages. To avoid this use :silent !{cmd}. The screen is not redrawn then.... But if you'...
B Layer's user avatar
  • 19.9k
1 vote
Accepted

How to open a command in a split window?

You can run :split before you run your :grep. Note that :split is not a command modifier, so you need to run the two commands as separate commands. You can separate them with |, as in: :split | grep ...
filbranden's user avatar
  • 29k
1 vote

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

Here's a potential solution. I'll use 4 test files. 3 contain the lines foo bar baz while the 4th contains any proper subset. The patterns of interest are the same 3 lines. Run :vimgrep with all ...
D. Ben Knoble's user avatar
  • 26.4k
1 vote
Accepted

Highlight results of :grep while in quickfix window

After experiments I have observed that matchadd() proposed by run_the_race highlights occurrences only in the quickfix window but not in the window with file buffers which would be even more desirable....
bloody's user avatar
  • 140
1 vote

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

With the help of @ChristianBrabandt, I finished this function: function! CustomReplace(target, newWord) call CustomGrep(a:target) let x = 0 let cnt = len(getqflist()) while x < cnt ...
Yves's user avatar
  • 1,023
1 vote

What is the green <92> that's in my file?

This is a win-1252 quote character which means you're not using the correct encoding. See Unicode characters 2018 and 2019. The encoding is also called CP1252. In most other encodings, characters ...
Alexis Wilke's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible