justinmk / vim-dirvish

Directory viewer for Vim :zap:
Other
1.18k stars 64 forks source link

Allow Shdo to manipulate filenames #212

Closed idbrii closed 2 years ago

idbrii commented 2 years ago

Would it be easy to give Shdo the power to manipulate filenames?

For example, given a dirvish buffer:

small_e.lua  
small_es.lua 
small_esw.lua

Selecting all and invoking:

:'<,'>Shdo mv {} {s/small/big/}.txt

Could produce:

mv "small_e.lua"   "big_e.lua"
mv "small_es.lua"  "big_es.lua"
mv "small_esw.lua" "big_esw.lua"

Renaming files like this with the current Shdo is cumbersome because you want the substitution to occur at the end of the line instead of the beginning.

However, maybe {} was specifically selected to be like find and because it's unlikely to occur in valid shellscript, but text inside the braces is common.

idbrii commented 2 years ago

On second thought, smarter use of :sub is probably better. I just need to remember zero-width atoms and I can do:

:%s/.*\zssmall/big/

That probably jives better with Dirvish's "be vimlike and rely on vim" philosophy.