lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] When should std::distance (not) be used?


From: Vadim Zeitlin
Subject: Re: [lmi] When should std::distance (not) be used?
Date: Mon, 23 Jan 2017 02:26:21 +0100

On Sun, 22 Jan 2017 03:06:19 +0000 Greg Chicares <address@hidden> wrote:

GC> That example shows how useful iterators can be in the general case,
GC> which is rather uncommon. But I think the annoyance can be removed
GC> with an overload for whole containers, which I've already pushed.

 Thanks, in the hindsight this seems a very obvious improvement, I have no
idea why I hadn't just suggested this, but what counts is that you did it
anyhow, of course.

GC> Let me ask a vim question. I'm changing lines like this:
GC>     if(!each_equal(NewLoanRealized_.begin(), NewLoanRealized_.end(), 0.0))
GC> to
GC>     if(!each_equal(NewLoanRealized_, 0.0))
GC> in this fashion:
GC> 
GC>  - '*' under each_equal [actually I used 'vim --cmd "vim each_equal *.?pp"]
GC>  - 'n' to go to a line that needs changing, e.g., the one above
GC>  - '3el' to go to the end of the first "NewLoanRealized_"
GC>  - '2d/,' and Enter
GC> 
GC> That works well, but
GC>  - '.' recalls only '2d/,' rather than '3el2d/,' and
GC>  - 'd/' replaces the current search item "each_equal" with ","
GC> so it's laborious to repeat the series of commands.
GC> 
GC> So instead of '2d/' I try 'v2f,hd', which doesn't spoil my '*' search.
GC> Well, better, 'v2t,d' so I don't need the 'h'. I can recall that with
GC> '.', but it doesn't include '3el'.
GC> 
GC> Is this something I should record? I.e.:
GC>   qk3elv2t,dq
GC> Now I can 'n' and '@k' (and '@@' subsequently).
GC> 
GC> Have I overlooked a simpler way?

 I would either use the replace comment (":s") which can be easily repeated
using "&" or "g&" or indeed record a macro and apply it using "@@". I think
I'd prefer the former here, but I don't know what is simpler and if there
is no better way (FWIW I'm a bit jealous that you've already discovered
macros, I think it took me many months of working with Vim before I
realized how useful they were).

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]