wincent / loupe

🔍 Enhanced in-file search for Vim
BSD 2-Clause "Simplified" License
143 stars 6 forks source link

Replace last search without manually deleting MagicString #17

Open miallo opened 3 years ago

miallo commented 3 years ago

If g:LoupeVeryMagic is enabled, typing :%s/ it will automatically fill out :%s/\v (which I usually want). But when I try to replace the last search, I want to execute :%s//replacement. If I don't delete the \v manually, it turns out as :%s/\v/replacement, which seems to insert the replacement before every character (with g-flag) or at the beginning of the line (without the flag).

Is it possible that directly adding another slash will remove the automatically inserted \v? I.e.: :%s/ => (automatically) :%s/\v => (when typing another /) :%s//

I could also take a look at this, but maybe someone has an idea on where I can start? This function seems to be responsible for inserting the \v after :%s/. So far I didn't write anything but my simple vimrc in VimScript, but I would be willing to learn it.

Or is :%s/\v/replacement actually a usefull command that other people use all the time and this would be annoying? This seems less usefull to me than replacing the last search.

wincent commented 3 years ago

I suspect :%s/\v/replacement is probably not all that useful. However, getting the proposed change right might be tricky. At the moment, Loupe will only ever insert characters in the commandline (ie. you press / and it "expands" to /\v). If we implement this change, it will now _delete characters (ie. you press / again and it replaces the \v/ with just /); I'm not sure if this is going to cause confusion. Might be worth gating behind an option, just in case.