:term and terminal color escape codes

105 views
Skip to first unread message

Suresh Govindachar

unread,
Oct 3, 2019, 11:05:46 AM10/3/19
to vim...@googlegroups.com

To view a file containing terminal color escape codes (file was created
by redirecting the stdout and stderr into it), I tried the suggestions
at
https://vi.stackexchange.com/questions/485/can-vim-interpret-terminal-color-escape-codes
-- but there was no difference compared to just opening the file and not
doing any of the following:

1) Opening foo.txt and sourcing AnsiEscPlugin.vim
2) Opening foo.txt and sourcing ColorizerPlugin.vim
3) Starting vi and doing ":term less foo.txt"

Ubuntu 16.04, VIM version: 8.1.229, Colorscheme: ChocolateLiquor

So how can one view files with terminal color escape codes?

Thanks,



Gary Johnson

unread,
Oct 3, 2019, 11:42:34 AM10/3/19
to vim...@googlegroups.com
I don't know about 2 and 3, but after sourcing AnsiEscPlugin.vim,
you need to execute the :AnsiEsc command. You will also need to
have AnsiEsc.vim in your autoload directory. You may also need to
source, or just have in your plugin directory, the cecutil.vim
script. I get errors from the :AnsiEsc command if I don't also
source cecutil.vim.

Regards,
Gary

Suresh Govindachar

unread,
Oct 3, 2019, 11:48:33 AM10/3/19
to vim...@googlegroups.com
Worked! Thanks.

Christian Brabandt

unread,
Oct 3, 2019, 12:17:55 PM10/3/19
to vim...@googlegroups.com
Have you read the answers?

> Am 03.10.2019 um 17:05 schrieb 'Suresh Govindachar' via vim_use <vim...@googlegroups.com>:
>
> 
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> --- You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/dd3295cf-3c70-8649-2a93-77e35c587596%40yahoo.com.

Marius Gedminas

unread,
Oct 3, 2019, 2:11:33 PM10/3/19
to 'Suresh Govindachar' via vim_use
On Thu, Oct 03, 2019 at 08:05:28AM -0700, 'Suresh Govindachar' via vim_use wrote:
> To view a file containing terminal color escape codes (file was created by
> redirecting the stdout and stderr into it), I tried the suggestions at
> https://vi.stackexchange.com/questions/485/can-vim-interpret-terminal-color-escape-codes
> -- but there was no difference compared to just opening the file and not
> doing any of the following:
>
> 1) Opening foo.txt and sourcing AnsiEscPlugin.vim
> 2) Opening foo.txt and sourcing ColorizerPlugin.vim

I once tried this approach (don't remember which plugin specifically),
and it was very slow.

> 3) Starting vi and doing ":term less foo.txt"

Instead do :term cat foo.txt

Or, if you want to use less, ask less to interpret the escape codes for
you -- :term less -R foo.txt

Marius Gedminas
--
Thus spake the master programmer:
"After three days without programming, life becomes meaningless."
-- Geoffrey James, "The Tao of Programming"
signature.asc

Suresh Govindachar

unread,
Oct 4, 2019, 8:46:16 AM10/4/19
to vim...@googlegroups.com
On 10/3/2019 9:17 AM, Christian Brabandt wrote:
> Have you read the answers?

I assume you are referring to the answers at stackexchange -- I did try
the three answers as specifically itemized (1,2,3) in the original post
(use of cat inside term was misleading since it did not allow scrolling
and the tail end of the file did not have any escape codes.)

If you are referring to the responses on this mailing list, "On
10/3/2019 8:43 AM, Gary Johnson" and "On 10/3/2019 8:15 AM, Marius
Gedminas" each explained the modifications needed for my attempts 1 and
3. I did respond to the list indicating that Johnson's tweaks did work
for me. Gedminas's tweaks did work too.

>
>> Am 03.10.2019 um 17:05 schrieb 'Suresh Govindachar' via vim_use <vim...@googlegroups.com>:
>>
>> ???
Reply all
Reply to author
Forward
0 new messages