gitgutter.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. *gitgutter.txt* A Vim plugin which shows a git diff in the gutter.
  2. Vim GitGutter
  3. Author: Andy Stewart <https://airbladesoftware.com/>
  4. Plugin Homepage: <https://github.com/airblade/vim-gitgutter>
  5. ===============================================================================
  6. CONTENTS *gitgutter*
  7. Introduction ................. |gitgutter-introduction|
  8. Installation ................. |gitgutter-installation|
  9. Windows ................. |gitgutter-windows|
  10. Commands ..................... |gitgutter-commands|
  11. Mappings ..................... |gitgutter-mappings|
  12. Autocommand .................. |gitgutter-autocommand|
  13. Status line .................. |gitgutter-statusline|
  14. Options ...................... |gitgutter-options|
  15. Highlights ................... |gitgutter-highlights|
  16. FAQ .......................... |gitgutter-faq|
  17. TROUBLESHOOTING .............. |gitgutter-troubleshooting|
  18. ===============================================================================
  19. INTRODUCTION *gitgutter-introduction*
  20. GitGutter is a Vim plugin which shows a git diff in the sign column.
  21. It shows which lines have been added, modified, or removed. You can also
  22. preview, stage, and undo individual hunks. The plugin also provides a hunk
  23. text object.
  24. The signs are always up to date and the plugin never saves your buffer.
  25. The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this
  26. one in 2013.
  27. ===============================================================================
  28. INSTALLATION *gitgutter-installation*
  29. Use your favourite package manager, or use Vim's built-in package support.
  30. Vim:~
  31. >
  32. mkdir -p ~/.vim/pack/airblade/start
  33. cd ~/.vim/pack/airblade/start
  34. git clone https://github.com/airblade/vim-gitgutter.git
  35. vim -u NONE -c "helptags vim-gitgutter/doc" -c q
  36. <
  37. Neovim:~
  38. >
  39. mkdir -p ~/.config/nvim/pack/airblade/start
  40. cd ~/.config/nvim/pack/airblade/start
  41. git clone https://github.com/airblade/vim-gitgutter.git
  42. nvim -u NONE -c "helptags vim-gitgutter/doc" -c q
  43. <
  44. ===============================================================================
  45. WINDOWS *gitgutter-windows*
  46. There is a potential risk on Windows due to `cmd.exe` prioritising the current
  47. folder over folders in `PATH`. If you have a file named `git.*` (i.e. with
  48. any extension in `PATHEXT`) in your current folder, it will be executed
  49. instead of git whenever the plugin calls git.
  50. You can avoid this risk by configuring the full path to your git executable.
  51. For example:
  52. >
  53. " This path probably won't work
  54. let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
  55. <
  56. Unfortunately I don't know the correct escaping for the path - if you do,
  57. please let me know!
  58. ===============================================================================
  59. COMMANDS *gitgutter-commands*
  60. Commands for turning vim-gitgutter on and off:~
  61. *gitgutter-:GitGutterDisable*
  62. :GitGutterDisable Turn vim-gitgutter off for all buffers.
  63. *gitgutter-:GitGutterEnable*
  64. :GitGutterEnable Turn vim-gitgutter on for all buffers.
  65. *gitgutter-:GitGutterToggle*
  66. :GitGutterToggle Toggle vim-gitgutter on or off for all buffers.
  67. *gitgutter-:GitGutterBufferDisable*
  68. :GitGutterBufferDisable Turn vim-gitgutter off for current buffer.
  69. *gitgutter-:GitGutterBufferEnable*
  70. :GitGutterBufferEnable Turn vim-gitgutter on for current buffer.
  71. *gitgutter-:GitGutterBufferToggle*
  72. :GitGutterBufferToggle Toggle vim-gitgutter on or off for current buffer.
  73. *gitgutter-:GitGutter*
  74. :GitGutter Update signs for the current buffer. You shouldn't
  75. need to run this.
  76. *gitgutter-:GitGutterAll*
  77. :GitGutterAll Update signs for all buffers. You shouldn't need to
  78. run this.
  79. Commands for turning signs on and off (defaults to on):~
  80. *gitgutter-:GitGutterSignsEnable*
  81. :GitGutterSignsEnable Show signs for the diff.
  82. *gitgutter-:GitGutterSignsDisable*
  83. :GitGutterSignsDisable Do not show signs for the diff.
  84. *gitgutter-:GitGutterSignsToggle*
  85. :GitGutterSignsToggle Toggle signs on or off.
  86. Commands for turning line highlighting on and off (defaults to off):~
  87. *gitgutter-:GitGutterLineHighlightsEnable*
  88. :GitGutterLineHighlightsEnable Turn on line highlighting.
  89. *gitgutter-:GitGutterLineHighlightsDisable*
  90. :GitGutterLineHighlightsDisable Turn off line highlighting.
  91. *gitgutter-:GitGutterLineHighlightsToggle*
  92. :GitGutterLineHighlightsToggle Turn line highlighting on or off.
  93. Commands for turning line number highlighting on and off (defaults to off):~
  94. NOTE: This feature requires Neovim 0.3.2 or higher.
  95. *gitgutter-:GitGutterLineNrHighlightsEnable*
  96. :GitGutterLineNrHighlightsEnable Turn on line highlighting.
  97. *gitgutter-:GitGutterLineNrHighlightsDisable*
  98. :GitGutterLineNrHighlightsDisable Turn off line highlighting.
  99. *gitgutter-:GitGutterLineNrHighlightsToggle*
  100. :GitGutterLineNrHighlightsToggle Turn line highlighting on or off.
  101. Commands for jumping between hunks:~
  102. *gitgutter-:GitGutterNextHunk*
  103. :GitGutterNextHunk Jump to the next [count] hunk.
  104. *gitgutter-:GitGutterPrevHunk*
  105. :GitGutterPrevHunk Jump to the previous [count] hunk.
  106. *gitgutter-:GitGutterQuickFix*
  107. :GitGutterQuickFix Load all hunks into the |quickfix| list. Note this
  108. ignores any unsaved changes in your buffers. The
  109. |g:gitgutter_use_location_list| option can be set to
  110. populate the location list of the current window
  111. instead. Use |:copen| (or |:lopen|) to open a buffer
  112. containing the search results in linked form; or add a
  113. custom command like this:
  114. >
  115. command! Gqf GitGutterQuickFix | copen
  116. <
  117. *gitgutter-:GitGutterQuickFixCurrentFile*
  118. :GitGutterQuickFixCurrentFile Same as :GitGutterQuickFix, but only load hunks for
  119. the file in the focused buffer. This has the same
  120. functionality as :GitGutterQuickFix when the focused
  121. buffer is empty.
  122. Commands for operating on a hunk:~
  123. *gitgutter-:GitGutterStageHunk*
  124. :GitGutterStageHunk Stage the hunk the cursor is in. Use a visual selection
  125. to stage part of an (additions-only) hunk; or use a
  126. range.
  127. To stage part of any hunk, first |GitGutterPreviewHunk|
  128. it, then move to the preview window, delete the lines
  129. you do not want to stage, and |write| or
  130. |GitGutterStageHunk|.
  131. *gitgutter-:GitGutterUndoHunk*
  132. :GitGutterUndoHunk Undo the hunk the cursor is in.
  133. *gitgutter-:GitGutterPreviewHunk*
  134. :GitGutterPreviewHunk Preview the hunk the cursor is in.
  135. To stage part of the hunk, move to the preview window,
  136. delete any lines you do not want to stage, and
  137. |GitGutterStageHunk|.
  138. To close a non-floating preview window use |:pclose|
  139. or |CTRL-W_z| or |CTRL-W_CTRL-Z|; or normal window-
  140. closing (|:quit| or |:close| or |CTRL-W_c|) if your cursor
  141. is in the preview window.
  142. To close a floating window when the cursor is in the
  143. original buffer, move the cursor.
  144. To close a floating window when the cursor is in the
  145. floating window use normal window-closing, or move to
  146. the original window with |CTRL-W_p|. Alternatively set
  147. |g:gitgutter_close_preview_on_escape| and use <Esc>.
  148. Two functions are available for your own logic:
  149. >
  150. gitgutter#hunk#is_preview_window_open()
  151. gitgutter#hunk#close_hunk_preview_window()
  152. <
  153. Commands for folds:~
  154. *gitgutter-:GitGutterFold*
  155. :GitGutterFold Fold all unchanged lines. Execute again to undo.
  156. Other commands:~
  157. *gitgutter-:GitGutterDiffOrig*
  158. :GitGutterDiffOrig Similar to |:DiffOrig| but shows gitgutter's diff.
  159. ===============================================================================
  160. AUTOCOMMANDS *gitgutter-autocommands*
  161. User GitGutter~
  162. After updating a buffer's signs vim-gitgutter fires a |User| |autocmd| with the
  163. event GitGutter. You can listen for this event, for example:
  164. >
  165. autocmd User GitGutter call updateMyStatusLine()
  166. <
  167. A dictionary `g:gitgutter_hook_context` is made available during its execution,
  168. which contains an entry `bufnr` that contains the buffer number being updated.
  169. User GitGutterStage~
  170. After staging a hunk or part of a hunk vim-gitgutter fires a |User| |autocmd|
  171. with the event GitGutterStage. Staging always happens in the current buffer.
  172. ===============================================================================
  173. MAPPINGS *gitgutter-mappings*
  174. You can disable all these mappings with:
  175. >
  176. let g:gitgutter_map_keys = 0
  177. <
  178. Hunk operations:~
  179. These can be repeated with `.` if you have vim-repeat installed.
  180. *gitgutter-<Leader>hp*
  181. <Leader>hp Preview the hunk under the cursor.
  182. *gitgutter-<Leader>hs*
  183. <Leader>hs Stage the hunk under the cursor.
  184. *gitgutter-<Leader>hu*
  185. <Leader>hu Undo the hunk under the cursor.
  186. You can change these mappings like this:
  187. >
  188. nmap ghp <Plug>(GitGutterPreviewHunk)
  189. nmap ghs <Plug>(GitGutterStageHunk)
  190. nmap ghu <Plug>(GitGutterUndoHunk)
  191. <
  192. Hunk jumping:~
  193. *gitgutter-]c*
  194. ]c Jump to the next [count] hunk.
  195. *gitgutter-[c*
  196. [c Jump to the previous [count] hunk.
  197. You can change these mappings like this:
  198. >
  199. nmap [c <Plug>(GitGutterPrevHunk)
  200. nmap ]c <Plug>(GitGutterNextHunk)
  201. <
  202. Hunk text object:~
  203. *gitgutter-ic* *gitgutter-ac* *gitgutter-text-object*
  204. "ic" operates on the current hunk's lines. "ac" does the same but also includes
  205. trailing empty lines.
  206. >
  207. omap ic <Plug>(GitGutterTextObjectInnerPending)
  208. omap ac <Plug>(GitGutterTextObjectOuterPending)
  209. xmap ic <Plug>(GitGutterTextObjectInnerVisual)
  210. xmap ac <Plug>(GitGutterTextObjectOuterVisual)
  211. <
  212. ===============================================================================
  213. STATUS LINE *gitgutter-statusline*
  214. Call the `GitGutterGetHunkSummary()` function from your status line to get a
  215. list of counts of added, modified, and removed lines in the current buffer.
  216. For example:
  217. >
  218. " Your vimrc
  219. function! GitStatus()
  220. let [a,m,r] = GitGutterGetHunkSummary()
  221. return printf('+%d ~%d -%d', a, m, r)
  222. endfunction
  223. set statusline+=%{GitStatus()}
  224. <
  225. ===============================================================================
  226. OPTIONS *gitgutter-options*
  227. The most important option is 'updatetime' which determines how long (in
  228. milliseconds) the plugin will wait after you stop typing before it updates the
  229. signs. Vim's default is 4000. I recommend 100. Note this also controls how
  230. long vim waits before writing its swap file.
  231. Most important option:~
  232. 'updatetime'
  233. Git:~
  234. |g:gitgutter_git_executable|
  235. |g:gitgutter_git_args|
  236. |g:gitgutter_diff_args|
  237. |g:gitgutter_diff_relative_to|
  238. |g:gitgutter_diff_base|
  239. Grep:~
  240. |g:gitgutter_grep|
  241. Signs:~
  242. |g:gitgutter_signs|
  243. |g:gitgutter_highlight_lines|
  244. |g:gitgutter_highlight_linenrs|
  245. |g:gitgutter_max_signs|
  246. |g:gitgutter_sign_priority|
  247. |g:gitgutter_sign_allow_clobber|
  248. |g:gitgutter_sign_added|
  249. |g:gitgutter_sign_modified|
  250. |g:gitgutter_sign_removed|
  251. |g:gitgutter_sign_removed_first_line|
  252. |g:gitgutter_sign_modified_removed|
  253. |g:gitgutter_set_sign_backgrounds|
  254. Hunk jumping:~
  255. |g:gitgutter_show_msg_on_hunk_jumping|
  256. Hunk previews:~
  257. |g:gitgutter_preview_win_floating|
  258. |g:gitgutter_floating_window_options|
  259. |g:gitgutter_close_preview_on_escape|
  260. Terminal:~
  261. |g:gitgutter_terminal_reports_focus|
  262. General:~
  263. |g:gitgutter_enabled|
  264. |g:gitgutter_map_keys|
  265. |g:gitgutter_async|
  266. |g:gitgutter_log|
  267. |g:gitgutter_use_location_list|
  268. *g:gitgutter_preview_win_location*
  269. Default: 'bo'
  270. This option determines where the preview window pops up as a result of the
  271. :GitGutterPreviewHunk command. Other plausible values are 'to', 'bel', 'abo'.
  272. See the end of the |opening-window| docs.
  273. *g:gitgutter_git_executable*
  274. Default: 'git'
  275. This option determines what git binary to use. Set this if git is not on your
  276. path.
  277. *g:gitgutter_git_args*
  278. Default: empty
  279. Use this option to pass any extra arguments to git when running git-diff.
  280. For example:
  281. >
  282. let g:gitgutter_git_args = '--git-dir=""'
  283. <
  284. *g:gitgutter_diff_args*
  285. Default: empty
  286. Use this option to pass any extra arguments to git-diff. For example:
  287. >
  288. let g:gitgutter_diff_args = '-w'
  289. <
  290. *g:gitgutter_diff_relative_to*
  291. Default: empty
  292. By default buffers are diffed against the index. Use this option to diff against
  293. the working tree. For example:
  294. >
  295. let g:gitgutter_diff_relative_to = 'working_tree'
  296. <
  297. *g:gitgutter_diff_base*
  298. Default: empty
  299. By default buffers are diffed against the index. Use this option to diff against
  300. a revision instead. For example:
  301. >
  302. let g:gitgutter_diff_base = '<some commit SHA>'
  303. <
  304. If you are looking at a previous version of a file with Fugitive (e.g.
  305. via :0Gclog), gitgutter sets the diff base to the parent of the current revision.
  306. This setting is ignore when the diff is relative to the working tree
  307. (|g:gitgutter_diff_relative_to|).
  308. *g:gitgutter_grep*
  309. Default: 'grep'
  310. The plugin pipes the output of git-diff into grep to minimise the amount of data
  311. vim has to process. Set this option if grep is not on your path.
  312. grep must produce plain-text output without any ANSI escape codes or colours.
  313. Use this option to turn off colours if necessary.
  314. >
  315. let g:gitgutter_grep = 'grep --color=never'
  316. <
  317. If you do not want to use grep at all (perhaps to debug why signs are not
  318. showing), set this option to an empty string:
  319. >
  320. let g:gitgutter_grep = ''
  321. <
  322. *g:gitgutter_signs*
  323. Default: 1
  324. Determines whether or not to show signs.
  325. *g:gitgutter_highlight_lines*
  326. Default: 0
  327. Determines whether or not to show line highlights.
  328. *g:gitgutter_highlight_linenrs*
  329. Default: 0
  330. Determines whether or not to show line number highlights.
  331. *g:gitgutter_max_signs*
  332. Default: 500 (Vim < 8.1.0614, Neovim < 0.4.0)
  333. -1 (otherwise)
  334. Sets the maximum number of signs to show in a buffer. Vim is slow at updating
  335. signs, so to avoid slowing down the GUI the number of signs is capped. When
  336. the number of changed lines exceeds this value, the plugin removes all signs
  337. and displays a warning message.
  338. When set to -1 the limit is not applied.
  339. *g:gitgutter_sign_priority*
  340. Default: 10
  341. Sets the |sign-priority| gitgutter assigns to its signs.
  342. *g:gitgutter_sign_allow_clobber*
  343. Default: 0 (Vim < 8.1.0614, Neovim < 0.4.0)
  344. 1 (otherwise)
  345. Determines whether gitgutter preserves non-gitgutter signs. When 1, gitgutter
  346. will not preserve non-gitgutter signs.
  347. *g:gitgutter_sign_added*
  348. *g:gitgutter_sign_modified*
  349. *g:gitgutter_sign_removed*
  350. *g:gitgutter_sign_removed_first_line*
  351. *g:gitgutter_sign_removed_above_and_below*
  352. *g:gitgutter_sign_modified_removed*
  353. Defaults:
  354. >
  355. let g:gitgutter_sign_added = '+'
  356. let g:gitgutter_sign_modified = '~'
  357. let g:gitgutter_sign_removed = '_'
  358. let g:gitgutter_sign_removed_first_line = '‾'
  359. let g:gitgutter_sign_removed_above_and_below = '_¯'
  360. let g:gitgutter_sign_modified_removed = '~_'
  361. <
  362. You can use unicode characters but not images. Signs must not take up more than
  363. 2 columns.
  364. *g:gitgutter_set_sign_backgrounds*
  365. Default: 0
  366. Only applies to existing GitGutter* highlight groups. See
  367. |gitgutter-highlights|.
  368. Controls whether to override the signs' background colours to match the
  369. |hl-SignColumn|.
  370. *g:gitgutter_preview_win_floating*
  371. Default: 0 (Vim)
  372. 0 (NeoVim which does not support floating windows)
  373. 1 (NeoVim which does support floating windows)
  374. Whether to use floating/popup windows for hunk previews. Note that if you use
  375. popup windows on Vim you will not be able to stage partial hunks via the
  376. preview window.
  377. *g:gitgutter_floating_window_options*
  378. Default:
  379. >
  380. " Vim
  381. {
  382. \ 'line': 'cursor+1',
  383. \ 'col': 'cursor',
  384. \ 'moved': 'any'
  385. }
  386. " Neovim
  387. {
  388. \ 'relative': 'cursor',
  389. \ 'row': 1,
  390. \ 'col': 0,
  391. \ 'width': 42,
  392. \ 'height': &previewheight,
  393. \ 'style': 'minimal'
  394. }
  395. <
  396. This dictionary is passed directly to |popup_create()| (Vim) or
  397. |nvim_open_win()| (Neovim).
  398. *g:gitgutter_close_preview_on_escape*
  399. Default: 0
  400. Whether pressing <Esc> in a preview window closes it.
  401. *g:gitgutter_terminal_reports_focus*
  402. Default: 1
  403. Normally the plugin uses |FocusGained| to force-update all buffers when Vim
  404. receives focus. However some terminals do not report focus events and so the
  405. |FocusGained| autocommand never fires.
  406. If this applies to you, either install something like Terminus
  407. (https://github.com/wincent/terminus) to make |FocusGained| work or set this
  408. option to 0.
  409. If you use tmux, try this in your tmux.conf:
  410. >
  411. set -g focus-events on
  412. <
  413. When this option is 0, the plugin force-updates the buffer on |BufEnter|
  414. (instead of only updating if the buffer's contents has changed since the last
  415. update).
  416. *g:gitgutter_enabled*
  417. Default: 1
  418. Controls whether or not the plugin is on at startup.
  419. *g:gitgutter_map_keys*
  420. Default: 1
  421. Controls whether or not the plugin provides mappings. See |gitgutter-mappings|.
  422. *g:gitgutter_async*
  423. Default: 1
  424. Controls whether or not diffs are run in the background. This has no effect if
  425. your Vim does not support background jobs.
  426. *g:gitgutter_log*
  427. Default: 0
  428. When switched on, the plugin logs to gitgutter.log in the directory where it is
  429. installed. Additionally it logs channel activity to channel.log.
  430. *g:gitgutter_use_location_list*
  431. Default: 0
  432. When switched on, the :GitGutterQuickFix command populates the location list
  433. of the current window instead of the global quickfix list.
  434. *g:gitgutter_show_msg_on_hunk_jumping*
  435. Default: 1
  436. When switched on, a message like "Hunk 4 of 11" is shown on hunk jumping.
  437. ===============================================================================
  438. HIGHLIGHTS *gitgutter-highlights*
  439. To change the signs' colours, specify these highlight groups in your |vimrc|:
  440. >
  441. highlight GitGutterAdd guifg=#009900 ctermfg=2
  442. highlight GitGutterChange guifg=#bbbb00 ctermfg=3
  443. highlight GitGutterDelete guifg=#ff2222 ctermfg=1
  444. <
  445. See |highlight-guifg| and |highlight-ctermfg| for the values you can use.
  446. If you do not like the signs' background colours and you do not want to update
  447. the GitGutter* highlight groups yourself, you can get the plugin to do it
  448. |g:gitgutter_set_sign_backgrounds|.
  449. To change the line highlights, set up the following highlight groups in your
  450. colorscheme or |vimrc|:
  451. >
  452. GitGutterAddLine " default: links to DiffAdd
  453. GitGutterChangeLine " default: links to DiffChange
  454. GitGutterDeleteLine " default: links to DiffDelete
  455. GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault
  456. <
  457. For example, to use |hl-DiffText| instead of |hl-DiffChange|:
  458. >
  459. highlight link GitGutterChangeLine DiffText
  460. <
  461. To change the line number highlights, set up the following highlight groups in
  462. your colorscheme or |vimrc|:
  463. >
  464. GitGutterAddLineNr " default: links to CursorLineNr
  465. GitGutterChangeLineNr " default: links to CursorLineNr
  466. GitGutterDeleteLineNr " default: links to CursorLineNr
  467. GitGutterChangeDeleteLineNr " default: links to CursorLineNr
  468. <
  469. For example, to use |hl-Underlined| instead of |hl-CursorLineNr|:
  470. >
  471. highlight link GitGutterChangeLineNr Underlined
  472. <
  473. To change the diff syntax colours used in the preview window, set up the diff*
  474. highlight groups in your colorscheme or |vimrc|:
  475. >
  476. diffAdded " if not set: use GitGutterAdd's foreground colour
  477. diffChanged " if not set: use GitGutterChange's foreground colour
  478. diffRemoved " if not set: use GitGutterDelete's foreground colour
  479. <
  480. Note the diff* highlight groups are used in any buffer whose 'syntax' is
  481. "diff".
  482. To change the intra-line diff highlights used in the preview window, set up
  483. the following highlight groups in your colorscheme or |vimrc|:
  484. >
  485. GitGutterAddIntraLine " default: gui=reverse cterm=reverse
  486. GitGutterDeleteIntraLine " default: gui=reverse cterm=reverse
  487. <
  488. For example, to use |hl-DiffAdd| for intra-line added regions:
  489. >
  490. highlight link GitGutterAddIntraLine DiffAdd
  491. <
  492. ===============================================================================
  493. FAQ *gitgutter-faq*
  494. a. How do I turn off realtime updates?
  495. Add this to your vim configuration in an |after-directory|:
  496. >
  497. autocmd! gitgutter CursorHold,CursorHoldI
  498. <
  499. b. I turned off realtime updates, how can I have signs updated when I save a
  500. file?
  501. If you really want to update the signs when you save a file, add this to your
  502. |vimrc|:
  503. >
  504. autocmd BufWritePost * GitGutter
  505. <
  506. c. Why can't I unstage staged changes?
  507. This plugin is for showing changes between the working tree and the index
  508. (and staging/undoing those changes). Unstaging a staged hunk would require
  509. showing changes between the index and HEAD, which is out of scope.
  510. d. Why are the colours in the sign column weird?
  511. Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly.
  512. Here are two ways you could change the colours:
  513. >
  514. highlight! link SignColumn LineNr
  515. highlight SignColumn guibg=whatever ctermbg=whatever
  516. <
  517. e. What happens if I also use another plugin which uses signs (e.g. Syntastic)?
  518. Vim only allows one sign per line. Vim-gitgutter will not interfere with
  519. signs it did not add.
  520. ===============================================================================
  521. TROUBLESHOOTING *gitgutter-troubleshooting*
  522. When no signs are showing at all:~
  523. 1. Try bypassing grep with:
  524. >
  525. let g:gitgutter_grep = ''
  526. <
  527. If it works, the problem is grep outputting ANSI escape codes. Use this
  528. option to pass arguments to grep to turn off the escape codes.
  529. 2. Verify git is on your path:
  530. >
  531. :echo system('git --version')
  532. <
  533. 3. Verify your git config is compatible with the version of git return by the
  534. command above.
  535. 4. Verify your Vim supports signs. The following should give 1:
  536. >
  537. :echo has('signs')
  538. <
  539. 5. Check whether the plugin thinks git knows about your file:
  540. >
  541. :echo getbufvar('','gitgutter').path
  542. <
  543. If the result is -2, the plugin thinks your file is not tracked by git.
  544. 6. Check whether the signs have been placed:
  545. >
  546. :sign place group=gitgutter
  547. <
  548. If you see a list of signs, this is a colorscheme / highlight problem.
  549. Compare these two highlight values:
  550. >
  551. :highlight GitGutterAdd
  552. :highlight SignColumn
  553. <
  554. If no signs are listed, the call to git-diff is probably failing. Turn on
  555. logging by adding the following to your vimrc, restart, reproduce the problem,
  556. and examing the gitgutter.log file in the plugin's directory.
  557. >
  558. let g:gitgutter_log = 1
  559. <
  560. When the whole file is marked as added:~
  561. If you use zsh, and you set "CDPATH", make sure "CDPATH" does not include the
  562. current directory.
  563. When signs take a few seconds to appear:~
  564. Try reducing 'updatetime':
  565. >
  566. set updatetime=100
  567. <
  568. Note this also controls how long vim waits before writing its swap file.
  569. When signs don't update after focusing Vim:~
  570. Your terminal probably isn't reporting focus events. Either try installing
  571. Terminus (https://github.com/wincent/terminus) or set:
  572. >
  573. let g:gitgutter_terminal_reports_focus = 0
  574. <
  575. vim:tw=78:et:ft=help:norl: