2017-09-14 106 views
1

我的Git提交消息包含一個空白字符,看起來像一個簡單的空間當我輸出git log或運行gitk。但是,當我用Vim打開Git提交消息時,空間顯示爲underbar,如屏幕截圖所示。怎麼能找出這是什麼性格?如果你能告訴我如何複製它,我會把它粘貼在這裏。什麼是我的Git提交消息中的空白字符?

Git commit message in Vim

的屏幕截圖顯示GIT中提交消息Vim中在的iTerm在MacOS。

+1

將光標移動到該字符處並輸入'ga'(在正常模式下)在屏幕底部顯示該字符的一些信息。 – Marth

+0

它輸出:'< > 160,十六進制00a0,八進制240'。看起來這是一個[non-breaking space](https://en.wikipedia.org/wiki/Non-breaking_space)。 – JJD

+1

隨時將您的評論轉換爲「完整」答案,以便我可以授予您答案標誌。 – JJD

回答

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. 

例如,使用ga與上a顯示的字符:

<a> 97, Hex 61, Octal 141 
+1

相關文章:[刪除非破壞性空格字符( )](http://www.markhneedham.com/blog/2013/02/23/ruby-stripping-out-a-non-breaking-space-character -nbsp /)。 – JJD

+0

如果您發現自己需要unicode名稱,您可能需要查看[characterize.vim](https://github.com/tpope/vim-characterize) –

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爲前綴,所以我記得它是十六進制的。

相關問題