it's really very simple. we all know that we can colorize our console output using ANSI escape sequences
but it's not very useful to remember and type them each time when we wanna change colors.
for example, if we want red text, we need something like this:
printf ("\033[0;31mhello\033[37;0m\n");
with some little help of vim we can make this easier:
printf ("\redhello\white");
where \red and \white are vim key mappings for setting red and white color, respectively.
here's how it's done:
imap \black \033[0;30m
imap \red \033[0;31m
imap \green \033[0;32m
imap \yellow \033[0;33m
imap \blue \033[0;34m
imap \magenta \033[0;35m
imap \cyan \033[0;36m
imap \white \033[0;37m
just a little note: you will need ANSI-capable terminal.
personally, i use xterm in both linux and windows environments, but as far as i know, most terminal emulators support this. most notable exception is the standard winnt tty window, also known as cmd.exe (which is the worst terminal emulator ever created anyways, and should be avoided).
Monday, September 22, 2008
colorful debug output to standard/error output with vim aid
Posted by
waker
at
1:32 PM
Labels: ansi escape sequences, debugging, vim, xterm colors
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment