[vim/vim] Add \- as a synonym to \{-\} in magic mode (Issue #20953)

12 views
Skip to first unread message

Mazunki Hoksaas

unread,
Aug 5, 2026, 2:18:26 PMAug 5
to vim/vim, Subscribed
mazunki created an issue (vim/vim#20953)

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
It's sometimes tedious to escape substitution patterns. Given a set of variables like {{foo}} where we want the output {{FOO}}, a solution would be :%s/{{[^}]\+}}/\U&/g in magic mode, and :%s/{{\[^}\]}}/\U&/ in nomagic mode. Thanks to the non-greedy \{-\}, this can be rewritten as :%s/{{.\{-\}}}/\U&/g, which is slightly more readable.

Ideally, I'd like to be able to rewrite this as :%s/{{.\-}}/\U&/g. To me and others, this seems far more readable.

Describe the solution you'd like
Currently, we have \+ for both magic and nomagic modes. We have * in magic mode, and \* in no-magic mode.

I'm suggesting that \{-\} remains unchanged for no-magic mode, but allows for \- as a synonym to \{-\} in magic and verymagic modes. Other flavour of regex have .*? for the same thing. I think \- makes sense since we already have \+ which has a similar role.


This should not affect consumers, since /\\ clearly states that "A backslash followed by a single character, with no special meaning, is reserved for future expansions".


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20953@github.com>

h_east

unread,
Aug 6, 2026, 1:22:18 AMAug 6
to vim/vim, Subscribed
h-east left a comment (vim/vim#20953)

JFYI, \{-} is the same as \{-\}.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20953/5200696564@github.com>

Mazunki Hoksaas

unread,
Aug 6, 2026, 5:40:57 AMAug 6
to vim/vim, Subscribed
mazunki left a comment (vim/vim#20953)

JFYI, \{-} is the same as \{-\}.

Thanks. I feel I've learned this a few times, but I end up escaping both sides because it looks more balanced to me, which feels more intuitive; so I end up forgetting. Great shoutout anyway.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20953/5202944665@github.com>

Houl

unread,
Aug 23, 2026, 1:31:55 PM (2 days ago) Aug 23
to vim/vim, Subscribed
Houl left a comment (vim/vim#20953)

I'd mostly prefer a pattern like {{[^}]\+}} that matches exactly what I want instead of {{.\{-}}} that might skip over arbitrary text.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20953/5387444061@github.com>

Mazunki Hoksaas

unread,
Aug 23, 2026, 2:47:41 PM (2 days ago) Aug 23
to vim/vim, Subscribed
mazunki left a comment (vim/vim#20953)

@Houl While that's certainly an option, and I believe it's more performant, in my experience most people find lazy-repetition to be far more readable than anti-classes.

Matter of taste, perhaps.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/20953/5387826831@github.com>

Reply all
Reply to author
Forward
0 new messages