“猫”和“猫”之间的不同表演和“ vim” [英] Different show between "cat" and "vim"

查看:72
本文介绍了“猫”和“猫”之间的不同表演和“ vim”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cat / tmp / test

>> cat /tmp/test
Hello World
Hello World
Hello World
Hello World

vim / tmp / test

>> vim /tmp/test
==>
1 ^[[1;31mHello World^[[0m
2 ^[[2;32mHello World^[[0m
3 ^[[5;33mHello World^[[0m
4 ^[[6;34mHello World^[[0m

对不起,我已经在Google上搜索了,但我仍然不知道如何让 vim / tmp / test cat / tmp / test 相同。

Sorry , I have google it , but I still don't know how to let vim /tmp/test show the same with cat /tmp/test.

您能帮我一下吗?谢谢。

Could you please give me a hand? thanks.

推荐答案

如果您要问为什么Vim中每行的开头和结尾都显示垃圾字符但不是使用cat,原因可能是它们正在格式化外壳程序用来为文本着色的转义序列。由于cat直接将其输出发送到shell,因此转义序列被解释为格式化命令,从而生成彩色文本。 Vim并非设计为使用这些格式序列,因此仅将它们显示为文本的一部分。

If you're asking why "garbage" characters are showing up at the beginning and end of each line in Vim but not with cat, the reason is probably that they are formatting escape sequences that the shell uses to color text. Since cat sends its output directly to the shell, the escape sequences are interpreted as formatting commands, producing the colored text. Vim is not designed to use these formatting sequences, so it just displays them as part of the text.

要摆脱转义符,可以手动将其删除,或者您可以使用sed之类的工具将其过滤掉如此处概述

To get rid of the escape characters, you could delete them manually, or you could use a tool like sed to filter them out as outlined here.

这篇关于“猫”和“猫”之间的不同表演和“ vim”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆