vi/vim鏄剧ず涓枃瀛楃骞朵笖鍘绘帀^M鐨勬柟娉�

澶勭悊椤圭洰xml閰嶇疆鏃秜im鎵撳紑缁忓父浼氱鍒颁腑鏂囨樉绀轰笉姝e父鐨勭幇璞★紝涔熷氨鏄紶璇翠腑鐨勪贡鐮侊紝鎼滅储鎵惧埌涓�涓В鍐冲姙娉曪紝璁板綍涓�涓嬶紝浣嗘槸gbk缂栫爜鐨勬甯镐簡锛寀tf8鐨勫張涓嶅浜嗐�備簬鏄◢寰敼浜嗕竴鐐广��
鐢ㄦ埛鐩綍涓嬪垱寤�.vimrc鏂囦欢
鍔犲叆

          set fileencodings=utf-8,gb2312,gbk,gb18030
          set termencoding=utf-8
          set fileformats=unix
          set encoding=prc

fileencodings涓璾tf-8瑕佸湪鍓嶉潰
杩欐牱灏辫兘姝e父鏄剧ず涓枃浜嗐�傞厤鍚坧ietty锛屽彲浠ュ畬鍏ㄦ甯告樉绀恒�佺紪杈戜腑鏂囦簡銆�

鍑犵鍘婚櫎^M鐨勬柟娉�
1銆�cat filename1 | tr -d "\r" > newfile
2銆� sed -e "s/^V^M//" filename > outputfilename
3銆乿i锛� 鐢╲i鎵撳紑鏂囦欢
(1) 鎸塃SC閿�
(2) 杈撳叆 :%s/^M//g
纭畾 ^M鏄娇鐢� "CTRL-V CTRL-M" 鑰屼笉鏄瓧闈笂鐨� ^M銆傝繖涓鍒欏紡灏嗘浛鎹㈡墍鏈夊洖杞︾鍓嶇殑 M涓虹┖($鏄负浜嗕繚璇�M鍑虹幇鍦ㄨ灏�)4銆佷竴浜沴inux鐗堟湰鏈� dos2unix 绋嬪簭锛屽彲浠ョ敤鏉ョ闄M
4銆佺敤vim
杈撳叆 :set notextmode

鍙儨锛岀粡杩囦笂闈㈢殑澶勭悊浠ュ悗锛宆M鏄笉瀛樺湪浜嗭紝浣嗘槸鎹㈣涓嶆垚鍔熴�傛墍鏈夌殑涓滆タ閮藉湪涓�琛屼笂闈紝鐪嬬潃寰堣垂鍔层�傝繖璇存槑澶勭悊鐨勬椂鍊欐枃浠剁己灏�"\n"锛屽彲浠ュ湪鏇挎崲鐨勬椂鍊欐坊鍔犱笂鍗冲彲锛�
cat filename | tr "\r" "\n" > newfile

娉�:^M 鍙互鐢⊿ublime Text缂栬緫鍣ㄦ煡鐪�

鍘熸枃閾炬帴:http://keepmovingxin.com/archives/34

你可能感兴趣的:(vi/vim鏄剧ず涓枃瀛楃骞朵笖鍘绘帀^M鐨勬柟娉�)