问题
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:\/\//gUse 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