How to include forward slash in vi search & replace

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: ", \, |

You can review this in the help subsystem using :h pattern-delimiter

Leave a Comment