New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ANSI color support in edit buffer #38834
Comments
On behalf of a friend who is too busy coding to report this problem, this still exists on macOS with VS Code 1.24.1. |
hello is the problem with ANSI color solved for editor and how, if it is? |
So ... vim community solved that problem in 2004. |
Here's an extract from another file that I generated with
The ✖should be displayed in red, the ✔in green, and the |
Currently, from what I can find, there's no extension that does this. It'd be a killer feature for VS Code for me! |
I was just looking for this feature too. My terminal can log to a text file, but when I view the file in VSCODE it's full of escape sequences. Would be nice have a way to either hide them or render them. |
no update????? |
Anything yet? |
This would be an awesome feature! |
Much needed feature |
can't believe this feature is still not provided 2+ year after it was raised... meanwhile, so many useless features have gone through the line... |
This awesome feature should be go on! |
Any status on this? Its very annoying |
This needs to be supported in diffs as well. ie: show the ANSI color in the diff view, rather than |
This would be very helpful if we could read gitlab raw ANSI output logs this way. |
The workaround for this issue that I've been using is:
Of course, the output is read-only but it lets me see the colored data in VScode without needing to switch to vim or Sublime. Edit: ansi2html is also a pip package |
@sharm294, thanks for tip. |
I was just wondering what all the weird SQL logs for rails meant, then I found this. This shows the log with ansi colors:
|
it's strange to me that this isn't considered basic functionality for a code editor as an irritating workaround, we can whip up a terminal and use |
@TobiasFaller The end-goal is to have the characters processed and not shown. It might only be possible if Microsoft includes builds this into VSC which is what this "issue" was opened for. Ideally, it would provide the same result that we get in terminal/ssh with cat. When I cat the file, the ANSI is processed and the characters are not shown. This allows me to select and copy lines and paste them into a document/email. With your extension, they are still present, and just changing the character's color to #000 still gets copied into the email. Your extension is better than nothing and I appreciate it, but it only takes care of half of this need. |
@JtMotoX How about creating a preview panel similar to the one in the Markdown extension: This preview could render the colored text into a web based view and act like a terminal. This would enable to edit the file as raw data in the editor with basic coloring and have the colored preview shown like in a terminal with interpreted escape codes. |
@TobiasFaller Now with that we are getting pretty close to the end-goal. Would be nice if Microsoft could add that built-in without requiring the Preview pane but your idea is probably as close as we are going to get with an extension. |
@JtMotoX I have now written a prototype which looks quite promising. The code needs to be refactored and some bugs are still present, but for a first implementation attempt this seems to work fine. |
It didn't work for me on MacOS, I'm not sure what I'm missing. I installed the plugin, and opened an ANSI encoded github log, selected VT100 in the bottom right corner, but it didn't change any colours at all. |
The plugin activation is still buggy (It's a pre-release). Try to open a second editor and then focus the initial editor view. |
@TobiasFaller Thank you for building this awesome extension! I tried it out and it works, but in the preview panel the escape characters are still shown. Would you make them hidden in future release as discussed above? |
@cedrusx I tried to reproduce the problem and implemented an additional filter for the preview. This feature will be in version 0.0.12. Feel free to give feedback if this solved your problem. |
I also found https://github.com/iliazeus/vscode-ansi which removes the escape characters, so maybe both extensions can be improved from each other |
@GaboFDC Thank you for the note. This extension seems to be quite new and has some interesting additional features, like support for using the theme colors and cancellation tokens for the rendering process. I might add these features to my current extension in the future. Removing the escape sequences is implemented quite similar though and uses a preview too. |
@iliazeus You are welcome to contribute to / copy from the existing plugin at https://github.com/TobiasFaller/vscode-vt100-syntax-highlight. |
And what do you do for diff of two files in Sublime? That was quite annoying in sublime ... |
There is a lot of good useful converation here. However, please, I would ask that people hold off from saying things such as:
Here's the problem: such comments don't move the conversation forward. They might be off-topic, impatient, or snarky. In any case, they squander people's valuable time and attention. So, please, let's work together to reduce the signal to noise ratio, not only in this particular issue but across all of our online discussions. Please think about these recommendations:
Finally, I would like to thank:
|
Thank you all for the feedback. Repository: Link to github.com The following features have now been implemented:
|
Can you configure VSC such that it opens *.log files into VT-100 Preview mode by default? Since preview doesn't allow you to search, I guess I would prefer a way to open log file in normal editor without escape code, but with color highlighting. I coude make the escape codes invisible with: |
As @bsburns mentions, this still doesn't quite solve the issue because in a long
It's actually fast and allows you to search... I wish there was a better solution, but this is the best I got. |
I fixed it using this thread |
Does this preserve ANSI escape codes including colors when saving to a |
This is really not an solution, but if you just want to see the logs in colored format for debugging purposes like me. Use "less -r file.log" or "type file.log" in windows. |
@bsburns There is now the option to open the preview for *.log files by default (https://marketplace.visualstudio.com/items?itemName=Tobias-Faller.vt100-syntax-highlighting#open-preview-directly-or-by-default). I would appreciate feedback. In a test build I enabled the search option for the WebPanel preview but it segfaults as soon as the document is switched when a search was active. I'll have to report a few bugs to VS Code before I'll be able to add a convenient search function that ignores escape sequences. |
@ReetiMauryaCrest Can you evaluate if the updated plugin contains everything for your use-case? Feedback is appreciated. |
Thank you for the updated extension information. This works great for my usecase, I can now easily see my logs with just one preview click, this helps a lot. |
Related on Stack Overflow: Can I display a file with ANSI color escape sequences in Visual Studio Code? @TobiasFaller you're welcome to write an answer showing the capabilities of your extension and how to use it there. Just make sure that if you do, you follow the rules about self-promotion. |
Now ANSI colors are supported in the debug console, I'd like to see it in the editor, something like SublimeANSI.
Steps to Reproduce:
ls --color | code
Reproduces without extensions: Yes
The text was updated successfully, but these errors were encountered: