SwitchReverse doesn't seem to work with regex?
let g:switch_mapping = ""
let g:switch_custom_definitions =
\ [
\ ['!NOTE', '!TIP', '!IMPORTANT','!CAUTION', '!WARNING'],
\ {
\ '\<\(\l\)\(\l\+\(\u\l\+\)\+\)\>': '\=toupper(submatch(1)) . submatch(2)',
\ '\<\(\u\l\+\)\(\u\l\+\)\+\>': "\\=tolower(substitute(submatch(0), '\\(\\l\\)\\(\\u\\)', '\\1_\\2', 'g'))",
\ '\<\(\l\+\)\(_\l\+\)\+\>': '\U\0',
\ '\<\(\u\+\)\(_\u\+\)\+\>': "\\=tolower(substitute(submatch(0), '_', '-', 'g'))",
\ '\<\(\l\+\)\(-\l\+\)\+\>': "\\=substitute(submatch(0), '-\\(\\l\\)', '\\u\\1', 'g')",
\ }
\ ]
nnoremap <Bar>> :Switch<CR>
nnoremap <Bar>< :SwitchReverse<CR>
I have this set up. !NOTE !TIP switch works fine. But reversing on the regex doesn't seem to work.
Yes, this is described in the help here: https://github.com/AndrewRadev/switch.vim/blob/df58397cfa36d2f428ddc2652ba32d1db2af6d02/doc/switch.txt#L63-L69
There is no way for the plugin to automatically reverse the direction of regex-based switches. A dictionary definition says "if you match this regex, perform this substitution". There is no way for the code to go in the other direction. If you have a list of words, it can be converted into regex + substitution in either direction.
If this is important to you, I could think of a method to describe regexes in both directions, but you'll have to essentially write each regex + substitution twice, and I make no promises on when I can get around to it.
I can see why there's this limitation. I'm happy with as it is. 🙂 thank you!