湯姆貓的筆記
筆記就是以免忘記
2012年3月4日 星期日
find and replace
檔案中要放入 regular express 的字串,包含 . (dot),
先開 vim 把 . 換成 \. 放入 RE search 才會對。
:%s/\./\\./g
:%s/old-string/new-string/g
g 代表該行中每個符合 old-string 都要換成 new-string
如果沒有加 g,只有 :%s/old-string/new-string 的話,
只會替換該行第一個符合的 string,該行其後符合的都跳過。
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言