Search code examples
vimfind-replace

How do you deal with escaping special characters in vim?


I am trying to search and replace one TTL (which is short for "title") with another TTL like below...

:%s/TTL:"\$\\sqrt{s} =  14\$ TeV"/TTL:"<S1B>, \$\\sqrt{s}\$ = 14 TeV/gc

to change the line below

TTL:"$\sqrt{s} = 14$ TeV"

into

TTL:"<S1B>, $\sqrt{s}$ = 14 TeV, <LUM> = 300 <IFB>",

Basically, when I try to search and replace TTL:"$\sqrt{s} 14$ TeV vim tells me that it can not find the pattern I was searching for. Do I need to include some character to like a backslash or something to help vim find it?


Solution

  • %s/TTL:"\$\\sqrt{s} = 14\$ TeV"/TTL:"<SIB>, \$\\sqrt{s}\$ = 14 TeV, <LUM> = 300
     <IFB>"/g