On 30.12.2023 08:00, Eli the Bearded wrote:
> In comp.editors, Janis Papanagnou <
janis_pap...@hotmail.com> wrote:
>> PS: Historically (IIRC), in Vi, there was just the # command
>> (but not the * which I saw later in Vim).
>
> I do not believe you. For starters, nvi has a completely different
> function bound to #, and nvi tries to be backwards compatible with vi.
I don't think that the '#' command (with the current semantic) was in
the _original_ Vi. (If that is how you interpreted "historically"). I
observed the command # with the current behavior when I regularly used
Vi starting around 1990 on AIX (and HPUX). And I'm positive - since I
recall to have been looking for that - that at these days there was no
'*' (as counterpart that matches in the opposite direction). - But
please correct me if I am wrong.
>
>> jump from a C function call backwards to find its declaration.
>> Application of Vi(m) broadened since then, and yet more useful
>> features and changes entered the Vim command base.
>
> It occurs to me that you may like the boundary free versions of * and #:
> prefix them with a g.
>
> :noremap * g*
> :noremap # g#
I didn't know of the 'g' variants, but 'g*' seems to behave equivalent
to '*' on my two-line test sample; i.e. when reaching the second line
it jumps from the punctuation character block to the letter a.
§%" §%" *+*+ §%" §%"
^ ^ ^ ^
§%" a §%" a *+*+ §%" a §%" a
^ ^ ^ ^
^ ^ ^ ^
So while 'g*' doesn't address the issue it is actually even worse since
without the \< and \> it then also matches other appearing 'a' in the
text.
I want to provide two more examples to explain my desire for a "better"
behavior with non-alpha character blocks.[*]
1) Matching (non-alpha) shell keywords (or other non-alpha constructs
that are so typical in shells)
f() {
: ${1:?}
}
: ${1:?}
echo "a: b"
Positioning at the first colon I want to find other standalone ones.
2) Matching ASN.1 identifiers (or other not pure-alpha identifiers)
direct-reference OBJECT IDENTIFIER OPTIONAL,
indirect-reference INTEGER OPTIONAL,
Positioning it in one of the "reference" substrings I want to find
the whole identifier (e.g. "direct-reference"), but not any string
with the substring reference.
In other words, a keyword and an identifier (beyond C and alike) has a
broader definition generally, and a quick-match for non-alpha strings
would be very convenient as I regularly observe in various editing
contexts.
I am aware that we cannot cover all matching combinations - e.g. how
should "an-id: 'a value'" be parsed; it might get non-trivial - but
a quick-search for space-separated entities would already be very
convenient as I've often experienced in my editing contexts.
Vim already supports a lot of such settings (breakat, isfname, isident,
iskeyword, and yet more even language specifics), so maybe there's a
not too complex way to achieve that.
Janis
[*] Note: Of course all searching can be done with regular search/regexp
but as I use * for quick match convenience I'd like to have it not only
for alpha sequences.