Closed Shatur closed 3 years ago
This can be done with the quickfix list, :grep
, and the standard plugin cfilter
(bundled with Neovim).
This can be done with the quickfix list, :grep, and the standard plugin cfilter (bundled with Neovim).
Of course, that's exactly what I meant (just forgot to mention cfilter
). But this method is not very convenient. In VSCode I can do the same with live preview and much faster.
So there are plenty of options here to do this.
cdo
. cdo can even do confirm.Example) Here is the things to do.
I have Telescope hooked up and I search for PerformanceHand
.
Results Are presented
Press C-q to pipe to QF list
CDO
Accepting Each Change (drop the c to not do that)
You need a set of items that are the things you wish to replace. vimgrep, FzF, or Telescope can all do this. You pipe them to a quickfix list. For telescope its C-q, I think its A-tab in FzF (i don't use), and vimgrep goes directly to QF list Use cdo. cdo can even do confirm.
This is the way I mentioned in the issue message. At the moment, I use exactly the same approach to replace things in files in Neovim. I also want to mention the very handy quickfix-reflector.vim plugin that allows me to edit things inside Quickfix and write to files on save.
But such approach have some limitations:
FOO
with BAR
and foo
with bar
)Perhaps I should have mentioned this right away. Updated the first post.
So, of course you can do anything in Vim without plugins, but sometimes they make life easier. Therefore, I proposed the idea of a plugin.
:grep
command<c-j>/<c-k>
in fzf?cfdo
?:cfdo %S/original/replacement/g
.You can do a :cfdo %S/original/replacement/g.
Didn't know it works this way. Thank you! Preserving case was most important to me. Perhaps I will just add custom keybindings for CFilter and will continue to replace strings in this way.
https://github.com/windwp/nvim-spectre
This just got posted to r/neovim and might be closer to vscode experience.
Looks interesting, will try it out, thanks!
Is there a way to use the search term input from telescope's live_grep
within the quickfix list?
I would like to set up a keymap which will open cdo
with the search term within a search replace statement:
cdo s/<live_grep_input>//gc
What? VSCode have a very convinient way to replace string across multiply files: In this menu, you can filter found by a specific file type, delete unsuitable entries and replace. And all this in real time with a preview of the result.
Why? In Neovim, you can use Telescope / FZF / grep + Quickfix window + Cfilter. But this approach have some limitations:
FOO
withBAR
andfoo
withbar
)So, it would be awesome to a more convinient solution.
Potential existing implementations: Unfortunately, I do not know of any similar plugin, neither in VimScript nor in Lua.