vim & colors from ANSI Escape Sequences: how to display in vim the same colors that are displayed with the cat command
The terminal output will be colored if the content of the file will be sent "as-is" to the terminal, without any modifications. However, vim and some other editors will escape meta characters in the text and instead maybe add some other color codes for their syntax highlighting, so this doesn't work.
Try dumping the file to the terminal with cat
, this should work. Some simple editors or pagers like less
might also work.
Edit: I have not found a way to let vim "pass-through" all the escape codes, but I have found this answer which links to this vim script, which parses the escape codes and uses the vim syntax highlighting to recreate the color codes in the output. According to its description, it should do exactly what you want (but I have not tested it).
Related videos on Youtube
skay-
Updated on September 18, 2022Comments
-
skay- over 1 year
i know that tracking retweets in this fashion:
Source -> User1 -> User2
is not possible as Twitter only gives you the original tweet and not any retweet of a retweet. Based on this.. do you think it might be possible to track down retweets based on followers of the originator of the tweet? For example, what I want to do is to get a retweet, find all users that have retweeted it and then find how those users are related to the person that had originally tweeted it. If B is not a follower of the originator but have retweeted a tweet… could it be that a person B that he follows is a follower of the originator of the tweet and B retweeted it so A eventually saw it?
Thanks in advance for any feedback.
-
John S Gruber over 11 yearsIt might help if you could mention how and with what program you are creating the file with the text in color, and how you are later trying to display it.
-
Olivier Pons over 11 yearsSorry if I wasn't precise enough. Quote my question: I'm echoing through Php. I.e. "
php -f filename
" and i'm echoing using this class here: if-not-true-then-false.com/2010/… -
Ciro Santilli OurBigBook.com about 10 yearsPossible cross site duplicate of: superuser.com/questions/358409/…
-
-
Olivier Pons over 11 yearsIs there a way to do this with vim (= precise not to escape)?
-
skay- almost 11 yearsThanks for the answer and the information you provided. It really seems better (less expensive) doing your approach.
-
Sina over 8 yearsIt didn't work with less but did work with more: cat ~/myfile.txt | more
-
matiu over 6 yearsThat script kind of works. It's a vimball, so to install it, gunzip it somewhere, then in vim ':source ansi.vba'. It handles a lot of escapes but not all - Another solution is 'less -R filename'.