Skip to main content
deleted 4 characters in body; edited title
Source Link
Martin Tournoij
  • 63.3k
  • 26
  • 199
  • 274

Is there a utilityway to convert a vimVim regex literal to different magic modes?

If I have a magic vimVim regex in a string literal, is there a utilityway to convert the whole regex into an alternative representation that uses a different magic mode, so I could paste that equivalent regex into source code?

For instance, if I want to convert this magic-mode pattern:

'\m-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>'

to very-magic-mode to make it more readable, something like:

'\v-=<\d+L=>|0[xX][0-9a-fA-F]+>'

I often make mistakes trying to convert them by hand.

Is there a utility to convert a vim regex literal to different magic modes?

If I have a magic vim regex in a string literal, is there a utility to convert the whole regex into an alternative representation that uses a different magic mode, so I could paste that equivalent regex into source code?

For instance, if I want to convert this magic-mode pattern:

'\m-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>'

to very-magic-mode to make it more readable, something like:

'\v-=<\d+L=>|0[xX][0-9a-fA-F]+>'

I often make mistakes trying to convert them by hand.

Is there a way to convert a Vim regex literal to different magic modes?

If I have a magic Vim regex in a string literal, is there a way to convert the whole regex into an alternative representation that uses a different magic mode, so I could paste that equivalent regex into source code?

For instance, if I want to convert this magic-mode pattern:

'\m-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>'

to very-magic-mode to make it more readable, something like:

'\v-=<\d+L=>|0[xX][0-9a-fA-F]+>'

I often make mistakes trying to convert them by hand.

Source Link
Mu Mind
  • 485
  • 3
  • 10

Is there a utility to convert a vim regex literal to different magic modes?

If I have a magic vim regex in a string literal, is there a utility to convert the whole regex into an alternative representation that uses a different magic mode, so I could paste that equivalent regex into source code?

For instance, if I want to convert this magic-mode pattern:

'\m-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>'

to very-magic-mode to make it more readable, something like:

'\v-=<\d+L=>|0[xX][0-9a-fA-F]+>'

I often make mistakes trying to convert them by hand.