vim AnsiEsc脚本
背景
在使用gitea的时候配置了彩色日志,使用tail
查看日志是彩色的,但是用vim打开,就像一堆乱码。这可怎么办呢?
使用tail
命令查看是这样的:
使用vim
打开是这样的:
解决方案:
AnsiEsc.vim : ansi escape sequences concealed, but highlighted as specified (conceal)
created by: Charles Campbell
script type: syntax
description:
Files with ANSI escape sequences look good when dumped onto a terminal that accepts them, but heretofore have been a distracting clutter when edited via vim. The AnsiEsc.vim file, when sourced with vim 7.3 or later, will conceal Ansi escape sequences but will cause subsequent text to be colored as the escape sequence specifies.You need to have a vim with conceal mode enabled; use has(“conceal”) to find out if the vim you’re using has that feature.
Without that conceal feature or with vim versions earlier than 7.3, the best that can be done is to suppress Ansi escape sequences with “Ignore” highlighting. AnsiEsc.vim v2 does that.
Cutting edge versions are available at http://www.drchip.org/astronaut/vim/index.html#ANSIESC .
Usage: edit a file containing escape sequences, then type
:AnsiEsc
install details:
1 2 3
vim AnsiEsc.vba.gz :so % :q
第一步到vim官网下载AnsiEsc
脚本
第二步安装AnsiEsc
|
|
|
|
接着按回车
|
|
第三步启用AnsiEsc
再用vim
打开日志文件输入:
|
|
这看起来就舒服多了!