Search code examples
regexvim

Vim regex substitution pattern not found


I have a regex substitution I would like to perform on Vim and the command I have is as follows:

:%s/\s\s(\w)(.*):\s(.*,)/const get\U$1\L$2 = state => $3/g

Problem is, it says the pattern is not found.

Here I have it working on regex101:

https://regex101.com/r/dOmgJy/1


Solution

  • correct regex for vim will be

    :%s/\s\s\(\w\)\(.*\):\s\(.*,\)/const get\U$1\L$2 = state => $3/g
    

    you need to escape the parenthesis.