我的Git提交消息中的空白字符是什么?

时间:2017-09-14 10:10:50

标签: git vim special-characters whitespace commit-message

当我输出git log或运行gitk时,我的Git提交消息包含一个空白字符,看起来像一个简单的空格。但是,当我用Vim打开Git提交消息时,空格显示为下划线,如屏幕截图所示。怎么能找出这是什么角色?如果你能告诉我如何复制它,我会把它贴在这里。

Git commit message in Vim

屏幕截图显示了MacOS中iTerm中Vim中的Git提交消息。

2 个答案:

答案 0 :(得分:3)

使用vim,您可以使用ga(在正常模式下)将光标放在字符上,以十进制,十六进制和八进制形式打印其ascii值。

来自:help ga

:as[cii]    or                  *ga* *:as* *:ascii*
ga          Print the ascii value of the character under the
            cursor in decimal, hexadecimal and octal.  For
            example, when the cursor is on a 'R':
                <R>  82,  Hex 52,  Octal 122 ~
            When the character is a non-standard ASCII character,
            but printable according to the 'isprint' option, the
            non-printable version is also given.  When the
            character is larger than 127, the <M-x> form is also
            printed.  For example:
                <~A>  <M-^A>  129,  Hex 81,  Octal 201 ~
                <p>  <|~>  <M-~>  254,  Hex fe,  Octal 376 ~
            (where <p> is a special character)
            The <Nul> character in a file is stored internally as
            <NL>, but it will be shown as:
                <^@>  0,  Hex 00,  Octal 000 ~
            If the character has composing characters these are
            also shown.  The value of 'maxcombine' doesn't matter.
            Mnemonic: Get ASCII value.

例如,将gaa上的字符一起使用会显示:

<a>  97,  Hex 61,  Octal 141

答案 1 :(得分:1)

如果您发现自己经常想要查看字符代码,可以将其放入状态行和/或标尺格式:

set laststatus=1
set statusline=%F\ %(%w%h%r%m%)%=%2v:%4l/%4L\ 0x%02B
set rulerformat=%25(%w%h%r%<%m%=%2v:%4l/%4L\ 0x%02B%)

最后的%02B总是将字符代码放在窗口的右边距(如果你的字符值大于255,它的宽度会增加)。我在前面添加了0x,所以我记得它是十六进制的。