[email protected] wrote:
Hi,

no,no,no...I LIKE context sensitive highlightning in vim! :)

But:
Some tools, which normally are made fpr output directly to
the console use ESC-sequences to color parts of the text.
>From time to time I use the tool 'script' to log all of
the text into a file to review it later (I cannot read
at the speed these are spitting out dozens of words... ;)

I like to use vim for that ... but these [XXX] escape
sequences makes reading the output a very diffcult task, since they
are not interpreted by vim.

Piping the output through col -b remove a part of those but
by far not all.

Is there any way to get back my love "pure ascii" ???

Solution 1: \nj will clear out junk sequences...

" ---------------------------------------------------------------------
" NoJunk: remove color sequences and whatnot from a script file {{{2
"    Usually I invoke this with \nj  (used to be \nc)
nmap  <silent> <Leader>nj    :set lz<bar>call <SID>NoJunk()<bar>set nolz<cr>
fun! s:NoJunk()
"  call Dfunc("NoJunk()")
 let keepmagic = &magic
 set magic
exe 'silent %s/\([^'."\<c-h>".']\+\)\(\%x08\+\)/\=strpart(submatch(1),0,strlen(submatch(1))-strlen(submatch(2)))/ge'
 exe '%s/'."\<Esc>".'\[[0-9;>]*[cmHCKr]//ge'
 exe 'silent %s/'."\<Esc>".'\[?\d\+[hl]//ge'
 exe 'silent %s/'."\<c-m>".'//ge'
 exe 'silent %s/'."\<Esc>".'][0-9;]\+k\=//ge'
 exe 'silent %s/'."\<c-g>".'//ge'
 exe 'silent %s/'."\<esc>".'[P\\]\(+q\x\+\)*//ge'
 exe 'silent %s/'."\<Esc>".'\[2J//ge'
 exe 'silent %s/'."\<Esc>".'=\(+q\x\+\)*\~//ge'
 exe 'silent %s/'."\<esc>".'='."\<esc>".'\[?\d\+;\d\+h//ge'
 exe 'silent %s/'."\<esc>".'[=>]//ge'
 let &magic= keepmagic
"  call Dret("NoJunk")
endfun

2. Solution 2: use AnsiEsc.vim:

The AnsiEsc plugin colorizes text according to ansi escape sequences; you can get the plugin from:

   http://vim.sourceforge.net/scripts/script.php?script_id=302   (stable)
http://mysite.verizon.net/astronaut/vim/index.html#ANSIESC (cutting edge)

It also works even better with Vince Negri's conceal patch, which you can get from

   http://vince.negri.googlepages.com/

I've always wished that Vince's patch had been incorporated into vim, but not thus far.

Anyway, with VN's patch, the Ansi escape sequences themselves are concealed, so only the colorized effects appear (except for the line where the cursor is). Without that patch, the Ansi escape sequences are colorized with Ignore highlighting -- so they take up space but are less intrusive.

Regards,
Chip Campbell


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en

Reply via email to