sponsor Vim development Vim logo Vim Book Ad

AnsiEsc.vim : ansi escape sequences concealed, but highlighted as specified (conceal)

 script karma  Rating 169/63, Downloaded by 6640    Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
script type
Files with ANSI escape sequences look good when dumped onto a terminal that accepts them, but have been a distracting clutter when edited via vim.  The AnsiEsc.vim file, when sourced, will conceal Ansi escape sequences but will cause subsequent text to be colored as the escape sequence specifies when used with Vince Negri's conceal patch.  AnsiEsc.vim v3 or later uses the conceal patch to accomplish this.

Without that conceal patch, the best that can be done is to suppress Ansi escape sequences with "Ignore" highlighting.  AnsiEsc.vim v2 does that.

VIM Developer's Corner:

Vince Negri's "conceal" patch to vim6.3 and vim7.0 allows one to suppress strings within a line; ie. in-line folding! This feature is ideal for Ansi escape sequence handling.  Starting with AnsiEsc's version 3 the <AnsiEsc.vim> script makes use of that new capability to display Ansi-sequence containing files.  The Ansi escape sequences themselves are concealed (except for the line where the cursor is), but they have their desired colorizing effect.  Note that you must have Vim7.0 with the +conceal option for the latest <AnsiEsc.vim> (v8) to work.  Apply Vince Negri's patch to the Vim 7.0 source code and compile Vim for "huge" features.  Once you've done that, simply source the <AnsiEsc.vim> file in when you want to see Ansi-escape sequenced text in Vim.

    Typical Compiling Directions:
To use the AnsiEsc v2, just source it in when you wish to; your vim version needs +syntax, which is fairly common.

To use the conceal-mode AnsiEsc (those with versions >= 3), you'll need to have a Vim that has been patched with Vince Negri's concealownsyntax patch; the version will show both +syntax and +conceal.

Typical compiling directions:

        * cd ..wherever../vim70/
        * browse http://sites.google.com/site/vincenegri/ for the conceal/ownsyntax patch
        * patch -p0 < conceal-ownsyntax.diff
        * make distclean
        * configure --with-features=huge
        * make
        * make install

(also see: vimtip#1308)
(alpha/beta version available at http://www.drchip.org/astronaut/vim/index.html#ANSIESC)
install details
Just source the file in whenever you wish to observe an approximation of what the ansi-escape sequenced file will look like.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
AnsiEsc.vba.gz 12 2010-12-13 7.0 Charles Campbell * changed conc -> cole for vim 7.3's built-in conceal mode
* included some additional escape sequences
AnsiEsc.vba.gz 11 2010-06-22 7.0 Charles Campbell supports several escape sequences such as <esc>[m , <esc>[2J, and <esc>[H.
AnsiEsc.vba.gz 10 2010-04-07 7.0 Charles Campbell AnsiEsc has 1 and 2 Ansi escape code sequences supported by fixed syntax highlighting rules; it now also builds custom syntax highlighting to support 3 and 4 Ansi Escape code sequences based on your current document.  So  \e[48;5;16m will now cause correct highlighting to follow, for example.
AnsiEsc.vba.gz 9 2009-03-18 7.0 Charles Campbell * AnsiEsc comes in plugin + autoload format: faster vim startup, and AnsiEsc only when you want it.
* Now provides a :AnsiEsc command totoggle ANSI escape sequence processing.

Works with Vince Negri's conceal patch (if your vim supports VN's conceal, then the ansi-escape sequences are suppressed except on the line you're editing).
AnsiEsc.vba.gz 8 2006-08-16 7.0 Charles Campbell Uses vim7.0's undercurl as a substitute for blinking (which Vim doesn't support), contains a small helpfile, and contains directions for getting Vince Negri's conceal patch for vim 7.0.
AnsiEsc_v2.vim 2 2004-11-24 6.0 Charles Campbell I mistakenly removed AnsiEsc v2 (which is the version which doesn't use Vince Negri's conceal).  This update restores it!
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo