Vim
vim 可以只顯示 ASCII 字元,而將其他字節視為二進制數據嗎?
但是,我已經知道
vim -b
,根據使用的語言環境,它會將多字節字元(如 UTF-8)顯示為單個字母。
vim
無論字元集如何,我如何要求只顯示 ASCII 可列印字元,並將其餘字元視為二進制數據?
使用時
vim -b
,這會將所有高位字元顯示為<xx>
:set encoding=latin1 set isprint= set display+=uhex
任何單字節編碼都可以工作,vim 對所有低位字元使用 ASCII 並將它們硬編碼為可列印。設置
isprint
為空會將其他所有內容標記為不可列印。設置uhex
會將它們顯示為十六進制。以下是每個命令後顯示的變化:
這聽起來像你在找什麼。來自 wiki 的這個技巧,
vim
標題為:強制 UTF-8 Vim 將 Latin1 讀取為 Latin1。$ vim -c "e ++enc=latin1" file.txt
您也可以從
vim
’s:help
中查看更多關於編碼的資訊。:help enc
摘自
:help enc
'encoding' 'enc' string (default: "latin1" or value from $LANG) global {only available when compiled with the +multi_byte feature} {not in Vi} Sets the character encoding used inside Vim. It applies to text in the buffers, registers, Strings in expressions, text stored in the viminfo file, etc. It sets the kind of characters which Vim can work with. See encoding-names for the possible values. NOTE: Changing this option will not change the encoding of the existing text in Vim. It may cause non-ASCII text to become invalid. It should normally be kept at its default value, or set when Vim starts up. See multibyte. To reload the menus see :menutrans. This option cannot be set from a modeline. It would most likely corrupt the text. NOTE: For GTK+ 2 it is highly recommended to set 'encoding' to "utf-8". Although care has been taken to allow different values of 'encoding', "utf-8" is the natural choice for the environment and avoids unnecessary conversion overhead. "utf-8" has not been made the default to prevent different behavior of the GUI and terminal versions, and to avoid changing the encoding of newly created files without your knowledge (in case 'fileencodings' is empty). ... ...