Why are ^M and ^[ being appended to my files?
I noticed that sometimes Vim shows ^M
at the end of every line, or ^[
in front of an open开发者_开发问答ing bracket [
.
What do these characters mean and how can I get rid of them?
I'm running Vim 7.3 on Debian.
^M is dos-style line endings. You can get rid of them by using the dos2unix program:
dos2unix (yourfile)
These are control characters. The ^M represents the carriage return, used in windows as the other answer already explain.
The ^[ is the escape character. When followed by a opening square bracket ("[") it probably means an ANSI escape sequence. See this article to know more:
http://en.wikipedia.org/wiki/ANSI_escape_code
And give it a try. For example, in your terminal:
echo ^[[7mHello World!^[[m
Where each ^[ can be inserted with controlVcontrol[. So the sequence of typing is actually:
... controlVcontrol[[7m ...
These are control characters. Here is a link on how to remove them in vi.
This article on Vim wiki should help you: File format.
Though the article title may seem to be different it does talk about line endings and unix/dos/macos file formats.
精彩评论