On 3 February 2017 at 20:30, Marc André Tanner <mat_AT_brain-dump.org> wrote:
> On Fri, Feb 03, 2017 at 10:00:37AM +0000, Raphaël Proust wrote:
> […]
>> :x/pattern/ t h c/replacement/
>
> Not sure this is flexible enough? How would you generalize this to
> operate on the n-th dot in a convenient way?
:x/pattern/ t5 h c/replacement/ ← pops five matches out, selects the
sixth and replaces it.
:x/pattern/ t2 T2 c/replacement/ ← pops the first two matches out,
then the last two matches out, then replaces all the others.
The idea of t and h is to mimic tail(1) and head(1). The
capitalisation (t/T, h/H) corresponds to passing positive or negative
counts to those filters (head -n 10/head -n -10, and similarly for
tail).
>
> I thought about introducing a count specifier for either `x` and `y`
> or `g` and `v`. Because these commands take a regular expression not
> an address the count is unambiguous here:
>
> x3/pattern/ command
> x/pattern/ g3 command
>
> would only execute command for the third match. Similarly, `y` and `v`
> would execute it for all but the third match.
I like this syntax, especially the g/v one (see below how it extends
better). I don't think it's sufficient. Here are example of things I
don't think this can do with suggestions on extending this syntax.
- select the last match (albeit x-1 and g-1 could be used),
- select all but the first (G1 could be used, but X1 could not),
- select all but the n first (again Gn),
- select all but the n last (G-n).
>> So currently `X` is more like vim's `windo`. I use `bufdo` more often.
>> I'm undecided whether offering both is worth the added complexity and
>> features.
>
> I think it would be much cleaner to add both variants rather than
> duplicate some functionality. If we had a proper way to loop through
> files some vi originated commands like `bdelete` might become obsolete
> and could be removed.
W for window, X for file?
Z, Y?
It's not ideal, especially because `w` is for write…
Alternatively, because these are less frequent than the other
operators (x, g, c, etc.), maybe they don't need to be single letters.
I have also started testing it and using the github issue tracker for
your project. I'll use this thread for the design discussion and the
issue tracker for minor things and other more specific improvements.
Let me know if these are not your preferred channels.
Ciao,
--
______________
Raphaël Proust
Received on Mon Feb 06 2017 - 11:25:35 CET