使用vim搜尋並取代含雙引號的網址字串

替換(substitute)的表示式:
:[range]s[ubstitute]/{pattern}/{string}/[flags]

:1,$s#href=""#href="http://mywebsite/"#

1,$:表示從頭到尾(也可以用%取代1,$)
分隔符號(separator)為#(Pound sign)



文章來源
The "separator" (usually '/' or '#')
The "separator" is a character which seperates the command name from the pattern, seperates the pattern from the substitution string, and the substitution string from the options. You can chose any(?) character as a separator, but usually the slash (/) is used. When substitutions contain the slash as a literal character you should chose some other character that is not contained in the pattern or substitutions string. And if this is not possible then you have to "escape" it with a backslash (\): ":s/\/path\/filename/\/newpath\/newfilename/"

沒有留言:

張貼留言