tags:

views:

122

answers:

3

I've a hard time understanding signs I see in my text editor Vim. I see signs like ^@ and ^A and ^M and ^F. What does this mean? Is there any structured list of these signs and their meaning?

Trying to google it is a dead end since Google will not search for "^@".

+6  A: 

Those signs are control characters. ^@ is a NUL or the 0 character, ^M is CR or character 13, etc. What this notation is in effect saying is that you're looking at just the lower 5 bits of an @, M or whatever.

An ASCII chart, e.g. this will help you sort most of them out. Find the character you're seeing in vim somewhere in the chart, and then its code is in the leftmost column.

Carl Smotricz
A: 

If you're seeing something like

^@F^@i^@l^@e

it's a representation of NULL and apparently is a bit tricky to get out of Vim. This article may give more information.

pierre
+4  A: 

When you see lots of binary characters in Vim, you should be careful that you are editing your files correctly and not corrupting anything. It is unusual to deal with text files that have a large number of binary characters.

Are you trying to edit a binary file? You should set Vim’s 'binary' option before loading the file (or start with vim -b) otherwise Vim will translate newline characters and perform other undesired conversions.

Are you editing a text file that has the wrong newlines? A symptom of this is ^M or ^J characters appearing at the end of your lines. Explore the 'fileformat' and 'fileformats' options in order to help Vim save the files with the proper newlines. If you are using version control, you can instruct it to convert newlines to and from your platform so that everyone is happy.

Do you see lots of ^@ (null) characters? Maybe this file is encoded in UTF-16 and Vim isn’t decoding it properly. Reload it with :e ++enc=utf-16, for example.

To see what value a character represents, position the cursor over it and type ga.

jleedev
Lots of good advice!
Carl Smotricz