How to include forward slash in vi search & replace

后端 未结 1 2040
情深已故
情深已故 2020-11-30 00:48

I have a file that contains the string usrbin. I want to search for usrbin and replace it with /usr/bin/.

I tried :%s/us

相关标签:
1条回答
  • 2020-11-30 01:49

    Here are two ways:

    • escape the / which is the default substitute separator: :s/usrbin/\/usr\/bin
    • use another substitute separator, e.g., using the hash # character: :s#usrbin#/usr/bin. Note that there are characters that you can't use as a separator: ", \, |
    0 讨论(0)
提交回复
热议问题