在 vim 中执行非正则表达式搜索/替换 [英] Perform a non-regex search/replace in vim
问题描述
在 vim 中进行搜索/替换时,我几乎从不需要使用正则表达式,所以不断地逃避一切是一种痛苦,有没有办法让它默认不使用正则表达式,或者有没有替代命令来完成这个?
When doing search/replace in vim, I almost never need to use regex, so it's a pain to constantly be escaping everything, Is there a way to make it default to not using regex or is there an alternative command to accomplish this?
举个例子,如果我想用 <
替换 <
,我只想输入 s/</</g
而不是 s/\</\<\;/g
As an example, if I want to replace <
with <
, I'd like to just be able to type s/</</g
instead of s/\</\<\;/g
推荐答案
对于 :s
命令,有一个禁用或强制魔法的快捷方式.要关闭魔法,请使用 :sno
像:
For the :s
command there is a shortcut to disable or force magic. To turn off magic use :sno
like:
:sno/search_string/replace_string/g
在这里找到:http://vim.wikia.com/wiki/Simplifying_regular_expressions_using_magic_and_no-magic
这篇关于在 vim 中执行非正则表达式搜索/替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!