I have this markdown line,


I want to replace it with,


So, I tried this,


Vim(version 81) says pattern not found.

  • 4
    Pro tip: use vim-sandwich or vim-surround, they both work great to change a pair of character quickly. No need to do it manually.
    – jdhao
    Commented Nov 17, 2020 at 8:35
  • 1
    Possible dupes: vi.stackexchange.com/q/21682/10604, vi.stackexchange.com/q/7264/10604
    – D. Ben Knoble
    Commented Nov 17, 2020 at 12:39
  • 1
    The error you're getting ("pattern not found") is due to [ starting a character class in a regex (see :help /[]. You need to escape it with a backslash. This should work: :%s/\[s/(s/g. But much better is to use something like vim-surround, which gives you commands to switch the [] pair with a () pair in a single command (cs]) anywhere inside that block.)
    – filbranden
    Commented Nov 17, 2020 at 18:00

1 Answer 1


You need to escape the opening square bracket:


For the whole replace, you can use:


  • Yes worked!! I did it two times for opening and closing brackets. :%s/\[s/(s/g and :%s/\g]/g)/g
    – atheros
    Commented Nov 17, 2020 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.