引用 http://graphics.csie.ntu.edu.tw/~jonathan/tpd/2008/06/get-rid-of-carrot-m/
:%s/^M$//g
2011年3月5日 星期六
Vim指令01: 取代字串
引用 http://vimregex.com/#substitute
:1,5s/java/scala/g
選取第1行到第5行,並將其中所有的java取代成scala
:%s/java/scala/g
選取全檔,並將其中所有的java取代成scala
:%s/[Rr]uby/Python/g
選取全檔,並將其中的Ruby和ruby都取代成Python
| :range s[ubstitute]/pattern/string/cgiI | |
| For each line in the range replace a match of the pattern with the string where: | |
c | Confirm each substitution |
g | Replace all occurrences in the line (without g - only first). |
i | Ignore case for the pattern. |
I | Don't ignore case for the pattern. |
:1,5s/java/scala/g
選取第1行到第5行,並將其中所有的java取代成scala
:%s/java/scala/g
選取全檔,並將其中所有的java取代成scala
:%s/[Rr]uby/Python/g
選取全檔,並將其中的Ruby和ruby都取代成Python
訂閱:
文章 (Atom)