Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim text coloring

I use echo -e to color my scripts output, it works fine when using standard output.

But when I redirect the output to a file, vim doesn't show the colors, instead of that it shows signs like this ^[[

example:

echo -e "\e[32m Green message\e[0m";
echo -e "\e[31m Red message\e[0m";

with vim :

^[[32m Green message^[[0m
^[[31m Red message^[[0m

How to fix this.

NB: cat shows the colors too!!

like image 997
Ould Abba Avatar asked Sep 08 '13 13:09

Ould Abba


People also ask

Can you highlight text in vim?

Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.

Does vim support syntax highlighting?

VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.

How do I enable syntax highlighting in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

How do I change the color of Vimrc?

vimrc (or . Here, you can set the default color scheme by modifying the colorscheme line and setting the theme you prefer. When manually configuring syntax highlighting, you can add individual instructions with the highlight command.


1 Answers

Use either the AnsiEsc Plugin by Dr. Chip or my Colorizer plugin. Both should be able to color those Terminal Escape sequences.

like image 73
Christian Brabandt Avatar answered Nov 24 '22 13:11

Christian Brabandt