Remove color codes from a file to view it in a text editor
If you pipe a console command, which colorizes console output, such as rspec or some rake tasks, to a file and you open it in a text editor, you will see a lot of color codes, such as ESC[35m
mingled with rest of the file content. These can make reading the file quite hard. Fortunately, you can easily remove this codes with a simple Find and Replace operation in Sublime Text 2. Just follow these steps:
- Open the file in Sublime Text.
- Find -> Replace
- Enable searching by regular expression (Shortcut Alt+R on Ubuntu)
- Find What:
\e\[\d+m
- Replace With - just leave empty.
- Click Replace All.
Written by Alex Popov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sublime text
Authors
Related Tags
#sublime text
#regular expression
#colors
#regexp
#control characters
#pipe
#console output
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#