what do the + signs mean in vimscript regex strings

扶醉桌前 提交于 2019-12-24 02:05:24

问题


You can find this syntax being commonly used in syntax vimscripts. For example you can find it in the file <vimdir>\syntax\python.vim on line 113 in vim 7.4 (win7):

syn match pythonEscape +\\[abfnrtv'"\\]+ contained

My simple question is what do the + signs mean at the either end of the regex string literal?

I could not find anything with :help literal-string and :help regex or steve losh's book. Where do you think I should have been looking?


回答1:


They are indeed the start and end of the regex, in vim you can use any character as a delimiter. I remember reading this in Drew Neil's book "Practical Vim", but I also found an example here: http://www.hacktux.com/vi/replace

Escaping Characters

You will have to escape out the slash if it is part of your search string:

%s/http:\/\//https:\/\//g

Use Any Delimiter

Alternatively, change your delimiter. It can be anything!

%s!http://!https://!g

From sidyll in the comments:

Just for the sake of completeness, you may want to add the official help reference: :h E146. This is explained in the flags section, one of the last paragraphs at :h s_flags



来源:https://stackoverflow.com/questions/36568561/what-do-the-signs-mean-in-vimscript-regex-strings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!