-R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences and OSC 8 hyperlink sequences are output in "raw" form. Unlike -r, the screen appearance is maintained correctly, provided that there are no escape sequences in the file other than these types of escape sequences. Color escape sequences are only supported when the color is changed within one line, not across lines. In other words, the beginning of each line is assumed to be normal (non-colored), regardless of any escape sequences in previous lines. For the purpose of keeping track of screen appearance, these escape sequences are assumed to not move the cursor.
OSC 8 hyperlinks are sequences of the form:
ESC ] 8 ; ... \7
The terminating sequence may be either a BEL character (\7) or the two-character sequence "ESC \".
ANSI color escape sequences are sequences of the form:
ESC [ ... m
where the "..." is zero or more color specification characters. You can make less think that characters other than "m" can end ANSI color escape sequences by setting the environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you can make less think that characters other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.
对于 less 命令,你可以尝试在终端中使用 -R 或 --RAW-CONTROL-CHARS 选项来显示控制字符,包括制表符。示例命令如下: less -R <file> 对于 vim ,你可以编辑其配置文件 ~/.vimrc (如果不存在,可以创建一个),将下面的内容添加到文件中: set paste 然后保存并退出,并重新启动 vim ,它将开启“粘贴模式”,在此模式下粘贴的文本将保留制表符。
无论是 less 还是 vim ,它们的行为都受到终端软件的限制。所以,你还可以尝试以下方法来修改终端软件的显示设置: