Search code examples
gitvimspecial-characterswhitespacecommit-message

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


My Git commit message contains a whitespace character which looks like a simple space when I output git log or run gitk. However, when I open the Git commit message with Vim the space is displayed as an underbar as shown in the screenshot. How can find out what character this is? I would paste it here if you can tell me how I can copy it.

Git commit message in Vim

The screenshot shows the Git commit message in Vim in iTerm on MacOS.


Solution

  • Using vim, you can use ga (in normal mode) with the cursor on the character to print its ascii value in decimal, hexadecimal and octal.

    From :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.
    

    For instance, using ga with the character on an a shows:

    <a>  97,  Hex 61,  Octal 141