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

2013年1月4日 星期五

show dos line ending mark ^M

vi 在開啟檔案時,會自動判斷他是 dos 還是 unix 格式。
避免把 dos ending 的 ^M 顯示出來,

所以在檢查一個 檔案 是不是 有 ending mark 時,會看不出來。

可以在 自己 home 的 .vimrc 加上: :set ffs=unix
強制以 unix format 開啟檔案,這樣就可以顯示出 ^M 了。



實際測試,開啟檔案後再下 command 沒效,要加在 .vimrc 裡才行。

2010年10月28日 星期四

remove the line ending ^M mark

DOS/Windows 的ˊ文件在 Vi 打開都會在 line ending 出現
^M

要移除。可以用 Vi 的 search and replace command:

:%s/search-word/replace-word/g

%s 命令是用 "/" 來區分,第一個 "/" 間隔是 search word,第二個 "/" 是 replace word。
尾巴的 "g" 是 Globally 的意思 (search and replace the whole document)

所以要 remove ^M 就要下:

:%s/^M//g

但是 控制字元 "^M" 在 vi 裡要分兩次input:

Control-V Control-M

這樣輸入完,就會看到 ^M

2010年10月10日 星期日

Convert Code to Html format

從這一頁看到的:Convert Code to Html in Vim

大概就是:
  • 開啟一個 edit buffer (file)
  • 把要 convert 的 code copy 過去
  • :TOhtml
這樣就 OK了。

convert 好會是整頁的 html page, white space 和 tab 都會被convert。
所以要自己選出要的部分。