ANSI Color styling and previewer for your text editor.
Forked from iliazeus/vscode-ansi and enhanced with more complete ANSI escape code and additional function support.
Screen.Recording.2025-09-20.at.09.41.03.mov
Select the ANSI Text
language mode to highlight text marked up with ANSI escapes. Files with the .ans
and .ansi
extensions will be highlighted by default.
Run the ANSI Text: Open Preview
command for the prettified read-only preview.
Clicking the preview icon in the editor title will open the preview in a new tab. Alt
-click to open in the current tab.
The extension fetches the colors from the current theme and aims to look as good as the built-in terminal.
Enhanced Support (v1.2.0+): This extension now supports a comprehensive range of ANSI escape sequences including:
- SGR (Select Graphic Rendition): Colors, text formatting (bold, italic, underline, etc.)
- Cursor Control: Position (H, f), movement (A-G), save/restore (s, u)
- DEC Private Modes: Terminal behaviour control (?...h/?...l) for cursor visibility, mouse tracking, alternate screen
- Screen Manipulation: Erase sequences (J, K), scroll control (S, T)
- OSC Commands: Window titles, color palette control, clipboard operations
- Character Sets: ASCII, line drawing, and international character sets
- Device Queries: Status reports and device attributes
See ENHANCED_ANSI_SUPPORT.md for complete documentation of supported sequences.
Basic colors and formatting:
8-bit colors:
24-bit colors:
-
Can files automatically be set to ANSI language mode?
You can configure automatic ANSI language mode for files matching specific glob patterns. By default,
.ans
and.ansi
files will automatically be set to ANSI language mode when opened, enabling escape sequence highlighting.You can customize this behaviour in VS Code settings using gitignore-style patterns:
{ "ansiPreviewer.autoLanguageModeFiles": [ "**/*.ans", "**/*.ansi", "*.log", // All .log files in any directory "logs/*.txt", // .txt files in logs folder "output.txt", // Specific filename "build/**" // All files in build directory ] }
Pattern support:
*.log
- matches.log
files in any directory (same as**/*.log
)logs/*.txt
- matches.txt
files only inlogs
folderbuild/**
- matches all files inbuild
directory and subdirectoriesoutput.txt
- matches files named exactlyoutput.txt
Set it to an empty array
[]
to disable automatic language mode setting entirely.