Vim: Support :s/foo/bar/g style substitutions when text is selected

Created on 25 Jul 2016  路  8Comments  路  Source: VSCodeVim/Vim

  • VSCode Version: 1.3.1
  • VsCodeVim Version: 0.1.3
  • OS: Ubuntu 16.04

Most helpful comment

@oheard definitely this command is useful and easy to implement, I'll add this ASAP.

All 8 comments

@oheard definitely this command is useful and easy to implement, I'll add this ASAP.

That is a large number of reactions. This looks like a good one to prioritize, @rebornix.

ha, didn't notice so many people drop reactions on it. Fixed via #525.

Is this in the latest release? I'm running 0.1.5.

I /think/ there's a change in that now when text is selected I can run the substitution command whereas I don't think I could before. The substitution is performed only on the first line however instead of line-by-line.

So for instance, if I have the following two lines selected...
foobar
foobaz
...then run s/foo/quirk/ only 'foobar' is changed to 'quirkbar'.

Using the /g modifier also only replaces the first line, leading me to believe that this is taking into account only the first line.

Thanks for looking into this. :-)

@oheard My exact steps are:

I type in

foobaz

Then I hit : which prefills '<,'> for me. I type the full command '<,'>s/foo/quirk/ and hit enter and the text is changed to:

quirkbaz

Is that what you are doing?

(Note that if you delete '<,'>, only the first of the two foos will be replaced with quirk, just like in Vim. It's kind of unfortunate since the textbar autoselects it - @rebornix, is there any way to work around that?)

Well spotted @johnfn. I didn't notice the prefilled/selected '<,'> because naturally as soon as I type ':' I immediately type 's', clearing the input.

Thanks for the feedback.

Cool, no worries @oheard!

@rebornix - is there any workaround here?

@johnfn Code always selects the placeholder input so it's impossible right now. But I've already filed an issue there https://github.com/Microsoft/vscode/issues/10582 and it's verified.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

orn688 picture orn688  路  3Comments

lucastheisen picture lucastheisen  路  3Comments

cckowin picture cckowin  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

st-schneider picture st-schneider  路  3Comments