问题
I have a file that contains the string usrbin. I want to search for usrbin and replace it with /usr/bin/.
I tried :%s/usrbin/usr/bin/g, but it's showing error E488: Trailing characters.
How do I include a forward slash in a search and replace?
回答1:
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:",\,|
来源:https://stackoverflow.com/questions/11823616/how-to-include-forward-slash-in-vi-search-replace