mhinz / mhinz/vim-grepper

Grepper in Vimscript function does not execute subsequent cdo command

Open
#259 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
1.2k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

I am writing a simple function to search the word under cursor and replace it automatically, something along the lines of
```
function! Replace() abort
Grepper -cword -noprompt -noopen
silent execute "cdo s/" . expand("") . "//g"
endfunction
```
however, I noticed that when using `vim-grepper` and `Grepper` as grep wrapper, the subsequent `cdo` command is not executed, namely the quickfix windows opens up and no replacement is done. If instead I use the standard `vimgrep %` with the above function all works as intended.

I suppose it may have to do with having to use `(GrepperOperator)` in a function rather than `Grepper` as command, or am I making some other trivial mistake (for instance there are flags to directly execute `cdo` commands after grepping)?

Contributor guide

Open the contributing guide

Research direction

Start at the implementation of the `Grepper` command and trace how it populates the quickfix list before the following `cdo` runs. Reproduce the function with `Grepper -cword -noprompt -noopen`, compare it with `vimgrep %`, and verify that the replacement executes after the quickfix results are ready.

Written by the indexing model from the issue text.

Assessment

Tech stack
vim
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.