On Wednesday, 26 August 2015 12:15:44 UTC-4, Charles Campbell wrote: > Quinn Strahl wrote: > > On Wednesday, 26 August 2015 01:31:34 UTC-4, Justin M. Keyes wrote: > >> On Tue, Aug 25, 2015 at 10:00 PM, Quinn Strahl <[email protected]> wrote: > >>> A difference in behaviour between :g and :<range>normal recently > >>> frustrated me, and I wonder if it's up for debate: > >>> > >>> :g does a pass on matching lines and marks them before performing the > >>> operation; this allows it to be generally undeterred by operations that > >>> include addition/deletion of lines. > >>> > >>> :<range>normal does not do this, and as a result, it can get "thrown off" > >>> by such operations. For (a trivial) example, on the hypothetical file: > >>> > >>> foo > >>> bar > >>> baz > >>> > >>> Performing :1,3normal yyp would produce the following result: > >>> > >>> foo > >>> foo > >>> foo > >>> foo > >>> bar > >>> baz > >>> > >>> Whereas the more intuitive result would be: > >>> > >>> foo > >>> foo > >>> bar > >>> bar > >>> baz > >>> baz > >>> > >>> There does exist a workaround, in the form of :<range>g/^/normal yyp -- > >>> simply using :g in a way guaranteed to match every line in the desired > >>> range -- but this is a bit of a compositional kludge. > >>> > >>> Would it be feasible to add the marking behaviour of :g to :normal, or is > >>> that not worth implementing / a feature? > >> Why do you want them to behave the same? They serve different > >> purposes. Or rather, :g serves a purpose, and :normal is behaving in > >> the typical way for a range command that performs edits/changes. > >> > >> > >> Justin M. Keyes > > I have on many occasions run into situations where it would be very handy > > if :normal worked the way :g does with respect to how it handles changes in > > number of lines during operation, and I have not run into any case (nor can > > I imagine one) where the current behaviour is favourable. It seems less > > intuitive and less useful for it to behave this way. > > > Why not use > > :[range]g/pattern/norm whatever > > Regards, > Chip Campbell
That's the workaround I'm using right now, but there are many cases where I want to operate on every line in the range, forcing me to use something like my previous example: :<range>g/^/norm whatever It feels hacky; I'm essentially trying to avoid what is arguably the primary function of :g (matching a subset of lines) just to get that line-marking behaviour for the :normal operation. It makes me wonder, is there any reason for :normal to lack that behaviour? It seems like an objective improvement. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
