/在 vi​​ 中搜索和替换? [英] / in vi Search and replace?

查看:35
本文介绍了/在 vi​​ 中搜索和替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vi中,搜索和替换,你如何转义'/'(正斜杠)以使其正确.在路径中说.

in vi, search and replace, how do you escape a '/' (forward slash) so that it is correct. Say in a path.

喜欢:/Users/tom/documents/pdfs/

like: /Users/tom/documents/pdfs/

:%s//Users/tom/documents/pdfs//<new text>/g  --FAILS (obviously)

:%s/\/Users/tom/documents/pdfs\//<new text>/g -- FAILS with a trailing error

:%s/'/Users/tom/documents/pdfs/'/<new text>/g -- FAILS with a trailing error

我错过了什么?

推荐答案

您也需要在内部对正斜杠进行转义.

You need to escape the forward slashes internally, too.

:%s/\/Users\/tom\/documents\/pdfs\//<new text>/g

这篇关于/在 vi​​ 中搜索和替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆