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

Mazunki Hoksaas (Vim Github Repository) <[email protected]> Wed, 05 Aug 2026 11:18:14 -0700
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/issues/[email protected]>
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 or view it on GitHub:
https://github.com/vim/vim/issues/20953
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/issues/[email protected]>

-- 
-- 
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].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/20953%40github.com.