轉載 vi替換windows換行符爲linux換行符

1.用vi打開指定文本文件:vi filename.clinux

2.按 Esc 鍵,進入命令模式;this

3.按 : 鍵 (按 Shift 鍵不放後,同時按 : 鍵)進入命令輸入狀態;編碼

4.在冒號後輸入:%s/^M//gcode

注:^M是一個字符不是輸入^和M兩個字符,get

  即按住 Ctrl 鍵不放,同時按 V 鍵產生^,依然按住 Ctrl 鍵不放,同時按 M 產生M。it

5.按 Enter 鍵,執行替換命令io

6.按 : 鍵 (按 Shift 鍵不放後,按 : 鍵)進入命令輸入狀態;dva

7.在冒號後輸入:wq  <-- 保存修改coding

8.按 Enter 鍵,執行保存命令file

IDE中文件編碼方式和行結束符設置:

1)Window 下的 VS2008 中,

點擊菜單[File]->[Advanced Save Options...],

在彈出的 "Advanced Save Options" 對話框中,

設置 Encoding 爲 Unicode (UTF-8 with signature) - Codepage 65001

設置 Line endings 爲 Unix (LF)

2)Ubuntu 下的 Code::Blocks 中,

點擊菜單[Settings]->[Editor...],

在彈出的 "Configure editor" 對話框中,

點擊左邊框中的 General settings 選項,

設置 Encoding 選項組中的

Use encoding when opening files 爲 UTF-8

Use this encoding 爲 As default encoding(bypassing C::B's auto-detection)

設置 End-of-line options 選項組中的

End-of-line mode:LF

相關文章
相關標籤/搜索