weirongxu / coc-explorer

📁 Explorer for coc.nvim
MIT License
1.14k stars 45 forks source link

How to run a vim command on all selected files? #585

Closed ic-768 closed 3 weeks ago

ic-768 commented 1 month ago

I use the mappings for toggleSelection() to select a few files. I see that normal() is supposed to allow me to run commands on these files, so I try to run :normal(:%s/test/foo/g)after selecting the files, but it doesn't work. The contents of the file are unchanged.

I'm obviously doing something wrong, I'd appreciate any help.

weirongxu commented 3 weeks ago

The normal will execute the action in the explorer buffer, so :s has no effect on the file.

I think we should add a quickfix action so that we can add the selected files to the quickfix list and then execute the operation via cfdo

ic-768 commented 3 weeks ago

This works great! Thanks so much for this!

One suggestion that I would like to mention: It's possible to add the same file multiple times to the quickfix list. I don't know if there are legitimate use cases for this, but even if there are, it would be helpful to be able to display some sort of indication that the file is in the quickfix list in the file explorer. That way we can know which files are in the list at a glance, and not erroneously add the same files multiple times.

weirongxu commented 3 weeks ago

Prevent adding duplicate files to quickfix on v0.27.2