« first day (1561 days earlier)      last day (2111 days later) » 

MJB
MJB
07:17
@Rich Thank you for your suggestion. I've tried the plugin, and with a workaround i can get it to do what i want.
@Rich You mentioned there are many different mechanisms to do the sort of editing i want. Could you give an example? For example, if i'd want to do a substitute on 2 different sections (line x-y and visual block z), how would i go about it in vanilla vim - if it's possible?
 
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:
:'<,'>s/foo/bar/g | 1,4&&
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 ...
Then do the substitute: :'a,'bs/foo/bar/g | 'c,'d&& | 'e,'f&&
...although personally if it's starting to get that complex I'd just run the substitutions for each range one at a time
 
3 hours later…
MJB
MJB
11:51
@Rich I think for my use case your last suggestion works best. I wasn't familiar with "&&". That's why i like vim, no matter how long you're using it, vim can make you feel like a newbie any day of the week.
Nice article also. I'm defenitely bookmarking that.

« first day (1561 days earlier)      last day (2111 days later) »