Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see

alt text

where I have ^M and ^[ at various places. The former seems to be enter, while the latter apparently the end/beginning of the line.

I would like to get the purple symbols out such that I can read the log -file better.

I run

:set fileformats=unix,dos,mac

but I get the same output.

How can you get the encoding/fileformat right?

share|improve this question
I've updated my answer with more information about vim. – Dennis Williamson Jul 4 '09 at 19:12
up vote 3 down vote accepted

^[ is another representation for Escape (pressing Ctrl-[ is the same as pressing the escape key - the carat represents the control key). These are the beginning of ANSI color sequences. I don't think vim is going to show those colors (unless there's a filter that processes them).

There is a plugin for vim called AnsiEsc that will display the results of ANSI color sequences in a file. In order to install that plugin, you'll need to install the Vimball plugin first. In order to take full advantage of AnsiEsc, you'll need to recompile vim with the patch described on the AnsiEsc page.

You have to set the fileformats before the file is loaded (or in your .vimrc file). It won't apply it to a file that's already loaded.

share|improve this answer
Thank you for your answers! --- You can see Screen's logs clearly by cat screenlog.0 | less -r – Masi Jul 4 '09 at 18:24

Alternative you can run s/\^M//g and s/\^[//g in vi to remove the offending characters but doesn't resolve the issue with the file handling. Do you know what encoding the file is using? You can guess by using file and it will give you info such as: "ASCII text, with CRLF line terminators"

NOTE: To enter the "^M" as "CTRL-V CTRL-M"

share|improve this answer
@Chealion: I have tried to use only the fileformat=unix. The file is screenlog.0 so the file extension is .0. --- Your command gives me screenlog.0: UTF-8 Unicode English text, with very long lines, with CRLF, CR line terminators, with escape sequences, with overstriking. – Masi Jul 4 '09 at 18:14
@Chealion: note that the "fileformat" option is different from the "fileformats" (plural) option. The former affects file writing; the latter affects file reading. – Greg Hewgill Jul 5 '09 at 0:08
@Greg My bad. Cleaned up my answer without the unnecessary bits. – Chealion Jul 5 '09 at 5:46

if it is an option you could try dos2unix (and its partner in crime unix2dos)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.