Save terminal buffer with colors?

23 views
Skip to first unread message

Tom M

unread,
Apr 12, 2023, 5:36:58 AM4/12/23
to vim_use
Hi all,

Is there any possibility to save the content of terminal buffer (to a file) with colors? I have terminal buffers with thousands of lines in scrollback and I need to save it for further reference. If I just yank the lines and paste into a normal buffer then all coloring is lost. Also the TOhtml plugin gives the text without colors.

Some programs output error messages in red color and so they are standing out and are easily spotted when scanning the terminal scrollback. For comparison: It's possible to copy the scrollback of gnome terminal as HTML and save it into file. Then later it's easy to open that file in a browser and read the lines with original colors. Search some info in it. Having something similar in vim terminal would be nice.

Thanks for your answers. Regards,

Tom M

Bram Moolenaar

unread,
Apr 12, 2023, 6:34:01 AM4/12/23
to vim...@googlegroups.com, Tom M
I don't think this is currently possible for scrollback. You can get
the visible text and attributes with term_scrape(). That can be used to
store the information somewhere, it should be possible to make a plugin
that outputs HTML.

It should not be difficult to make term_scrape() work for text that has
scrolled out of view. I wonder how to indicate the line number, perhaps
with a negative number? Thus -1 would be the line above the first
visible line. Using an absolute number is made difficult by the
'termwinscroll' value, lines at the start may have been deleted.

--
Vi beats Emacs to death, and then again!
http://linuxtoday.com/stories/5764.html

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages