顯示具有 vim 標籤的文章。 顯示所有文章
顯示具有 vim 標籤的文章。 顯示所有文章

2011年3月5日 星期六

在 Vim 下去掉 ^M

引用 http://graphics.csie.ntu.edu.tw/~jonathan/tpd/2008/06/get-rid-of-carrot-m/


:%s/^M$//g

Vim指令01: 取代字串

引用 http://vimregex.com/#substitute

: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 - 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