What do these signs mean in Vim?

匿名 (未验证) 提交于 2019-12-03 08:35:02

问题:

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 "^@".

回答1:

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.



回答2:

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.



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!