gitgutter.txt 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. *gitgutter.txt* A Vim plugin which shows a git diff in the gutter.
  2. Vim Git Gutter
  3. Author: Andy Stewart <http://airbladesoftware.com/>
  4. Plugin Homepage: <https://github.com/airblade/vim-gitgutter>
  5. ===============================================================================
  6. CONTENTS *GitGutterContents*
  7. 1. Introduction ................. |GitGutterIntroduction|
  8. 2. Installation ................. |GitGutterInstallation|
  9. 3. Usage ........................ |GitGutterUsage|
  10. 4. Commands ..................... |GitGutterCommands|
  11. 5. CUSTOMISATION................. |GitGutterCustomisation|
  12. 6. FAQ .......................... |GitGutterFAQ|
  13. ===============================================================================
  14. 1. INTRODUCTION *GitGutterIntroduction*
  15. *GitGutter*
  16. Vim Git Gutter is a Vim plugin which shows a git diff in the 'gutter' (sign
  17. column). It shows whether each line has been added, modified, and where lines
  18. have been removed.
  19. This is a port of the Git Gutter plugin for Sublime Text 2.
  20. ===============================================================================
  21. 2. INSTALLATION *GitGutterInstallation*
  22. If you don't have a preferred installation method, I recommend installing
  23. pathogen.vim, and then simply copy and paste:
  24. >
  25. cd ~/.vim/bundle
  26. git clone git://github.com/airblade/vim-gitgutter.git
  27. <
  28. Or for Vundle users:
  29. Add Bundle 'airblade/vim-gitgutter' to your |vimrc| and then:
  30. - either within Vim: :BundleInstall
  31. - or in your shell: vim +BundleInstall +qall
  32. ===============================================================================
  33. 3. USAGE *GitGutterUsage*
  34. You don't have to do anything: it just works.
  35. ===============================================================================
  36. 4. COMMANDS *GitGutterCommands*
  37. Commands for turning Git Gutter on and off:
  38. :GitGutterDisable *:GitGutterDisable*
  39. Explicitly turn Git Gutter off.
  40. :GitGutterEnable *:GitGutterEnable*
  41. Explicitly turn Git Gutter on.
  42. :GitGutterToggle *:GitGutterToggle*
  43. Explicitly turn Git Gutter on if it was off and vice versa.
  44. :GitGutter *:GitGutter*
  45. Update signs for the current buffer.
  46. :GitGutterAll *:GitGutterAll*
  47. Update signs across all buffers.
  48. Commands for turning signs on and off (defaults to on):
  49. :GitGutterSignsEnable *:GitGutterSignsEnable*
  50. Explicitly turn line signs on.
  51. :GitGutterSignsDisable *:GitGutterSignsDisable*
  52. Explicitly turn line signs off.
  53. :GitGutterSignsToggle *:GitGutterSignsToggle*
  54. Explicitly turn line signs on if it was off and vice versa.
  55. Commands for turning line highlighting on and off (defaults to off):
  56. :GitGutterLineHighlightsEnable *:GitGutterLineHighlightsEnable*
  57. Explicitly turn line highlighting on.
  58. :GitGutterLineHighlightsDisable *:GitGutterLineHighlightsDisable*
  59. Explicitly turn line highlighting off.
  60. :GitGutterLineHighlightsToggle *:GitGutterLineHighlightsToggle*
  61. Explicitly turn line highlighting on if it was off and vice versa.
  62. Commands for jumping between marked hunks:
  63. :GitGutterNextHunk *:GitGutterNextHunk*
  64. Jump to the next marked hunk. Takes a count.
  65. :GitGutterPrevHunk *:GitGutterPrevHunk*
  66. Jump to the previous marked hunk. Takes a count.
  67. Commands for staging or reverting individual hunks:
  68. :GitGutterStageHunk *:GitGutterStageHunk*
  69. Stage the hunk the cursor is in.
  70. :GitGutterRevertHunk *:GitGutterRevertHunk*
  71. Revert the hunk the cursor is in.
  72. :GitGutterPreviewHunk *:GitGutterPreviewHunk*
  73. Preview the hunk the cursor is in.
  74. ===============================================================================
  75. 5. CUSTOMISATION *GitGutterCustomisation*
  76. You can customise:
  77. - The sign column's colours
  78. - The signs' colours and symbols
  79. - Line highlights
  80. - Extra arguments for git-diff
  81. - Key mappings
  82. - Whether or not to escape grep (defaults to no)
  83. - Whether or not vim-gitgutter is on initially (defaults to on)
  84. - Whether or not signs are shown (defaults to yes)
  85. - Whether or not line highlighting is on initially (defaults to off)
  86. - Whether or not vim-gitgutter runs in realtime (defaults to yes)
  87. - Whether or not vim-gitgutter runs eagerly (defaults to yes)
  88. Please note that vim-gitgutter won't override any colours or highlights you've
  89. set in your colorscheme.
  90. SIGN COLUMN
  91. By default vim-gitgutter will make the sign column look like the line number
  92. column (i.e. the |hl-LineNr| highlight group).
  93. To customise your sign column's background color, first tell vim-gitgutter to
  94. leave it alone:
  95. >
  96. let g:gitgutter_override_sign_column_highlight = 0
  97. <
  98. And then either update your colorscheme's |hlSignColumn| highlight group or set
  99. it in your |vimrc|:
  100. Desired appearance Command ~
  101. Same as line number column highlight clear SignColumn
  102. User-defined (terminal Vim) highlight SignColumn ctermbg={whatever}
  103. User-defined (graphical Vim) highlight SignColumn guibg={whatever}
  104. SIGNS' COLOURS AND SYMBOLS
  105. To customise the colours, set up the following highlight groups in your
  106. colorscheme or |vimrc|:
  107. >
  108. GitGutterAdd " an added line
  109. GitGutterChange " a changed line
  110. GitGutterDelete " at least one removed line
  111. GitGutterChangeDelete " a changed line followed by at least one removed line
  112. <
  113. You can either set these with `highlight GitGutterAdd {key}={arg}...` or link
  114. them to existing highlight groups with, say:
  115. >
  116. highlight link GitGutterAdd DiffAdd
  117. <
  118. To customise the symbols, add the following to your |vimrc|:
  119. >
  120. let g:gitgutter_sign_added = 'xx'
  121. let g:gitgutter_sign_modified = 'yy'
  122. let g:gitgutter_sign_removed = 'zz'
  123. let g:gitgutter_sign_modified_removed = 'ww'
  124. <
  125. LINE HIGHLIGHTS
  126. Similarly to the signs' colours, set up the following highlight groups in your
  127. colorscheme or |vimrc|:
  128. >
  129. GitGutterAddLine " default: links to DiffAdd
  130. GitGutterChangeLine " default: links to DiffChange
  131. GitGutterDeleteLine " default: links to DiffDelete
  132. GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault
  133. <
  134. EXTRA ARGUMENTS FOR GIT-DIFF
  135. To pass extra arguments to git-diff, add this to your |vimrc|:
  136. >
  137. let g:gitgutter_diff_args = '-w'
  138. <
  139. KEY MAPPINGS
  140. To disable all key maps:
  141. >
  142. let g:gitgutter_map_keys = 0
  143. <
  144. To change the hunk-jumping maps (defaults shown):
  145. >
  146. nmap [c <Plug>GitGutterPrevHunk
  147. nmap ]c <Plug>GitGutterNextHunk
  148. <
  149. To change the hunk-staging/reverting/previewing maps (defaults shown):
  150. >
  151. nmap <Leader>hs <Plug>GitGutterStageHunk
  152. nmap <Leader>hr <Plug>GitGutterRevertHunk
  153. nmap <Leader>hp <Plug>GitGutterPreviewHunk
  154. <
  155. TO ESCAPE GREP
  156. To avoid any alias you have for grep, use this:
  157. >
  158. let g:gitgutter_escape_grep = 1
  159. <
  160. TO TURN OFF VIM-GITGUTTER BY DEFAULT
  161. Add to your |vimrc|
  162. >
  163. let g:gitgutter_enabled = 0
  164. <
  165. TO TURN OFF SIGNS BY DEFAULT
  166. Add to your |vimrc|
  167. >
  168. let g:gitgutter_signs = 0
  169. <
  170. Note that the sign column will still be present if you have line highlighting
  171. switched on.
  172. TO TURN ON LINE HIGHLIGHTING BY DEFAULT
  173. Add to your |vimrc|
  174. >
  175. let g:gitgutter_highlight_lines = 1
  176. <
  177. TO STOP VIM-GITGUTTER RUNNING IN REALTIME
  178. Add to your |vimrc|
  179. >
  180. let g:gitgutter_realtime = 0
  181. <
  182. TO STOP VIM-GITGUTTER RUNNING EAGERLY
  183. Add to your |vimrc|
  184. >
  185. let g:gitgutter_eager = 0
  186. <
  187. ===============================================================================
  188. 6. FAQ *GitGutterFAQ*
  189. a. Why are the colours in the sign column weird?
  190. Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly.
  191. Please see |GitGutterCustomisation| on customising the sign column.
  192. b. What happens if I also use another plugin which uses signs (e.g. Syntastic)?
  193. Vim only allows one sign per line. Before adding a sign to a line,
  194. vim-gitgutter checks whether a sign has already been added by somebody else.
  195. If so it doesn't do anything. In other words vim-gitgutter won't overwrite
  196. another plugin's signs. It also won't remove another plugin's signs.