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

What is the whitespace character is in my Git commit message?

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

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

使用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

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

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 总是将字符代码放在 window 的右边距上(如果您的字符值大于 255,它的宽度会增加)。我在它前面加上 0x 只是为了记住它是十六进制的。