1 hour later…
08:27
@MJB It probably depends on what you're trying to do. For that example, I think the simplest is first to do the substitute on the visual block by typing
:s/foo/bar/g
(So you actually run :'<,'>s/foo/bar/g
because Vim prepopulates the command line) and then do :x,y&&
to run the same substitution on lines x-y
Here's another plugin for multiple selections, that might be better suited for what you're trying to do
If you need it to be a single undoable operation, you can run both the substitutions in a single ex command:
This is an article people often cite offering solutions for various problems requiring edits to multiple locations
Going back to your substitute example, if you have more than 2 sections and you don't want to have to type a whole bunch of line numbers into the command line, you could instead use marks to delimit each section. So navigate to the start of the first section and type
ma
, then to the end and type mb
, then to the start of the second section: type mc
, to the end: type md
...
3 hours later…
« first day (1561 days earlier) ← previous day next day → last day (2099 days later) »