aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-gitgutter/doc/gitgutter.txt
blob: d4bb7747a52960e7e3591bf71ac73964ee9adbf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
*gitgutter.txt*              A Vim plugin which shows a git diff in the gutter.


                           Vim Git Gutter


Author:            Andy Stewart <http://airbladesoftware.com/>
Plugin Homepage:   <https://github.com/airblade/vim-gitgutter>

===============================================================================
CONTENTS                                                    *GitGutterContents*

  1.  Introduction ................. |GitGutterIntroduction|
  2.  Installation ................. |GitGutterInstallation|
  3.  Usage ........................ |GitGutterUsage|
  4.  Commands ..................... |GitGutterCommands|
  5.  Autocommand .................. |GitGutterAutocmd|
  6.  CUSTOMISATION................. |GitGutterCustomisation|
  7.  FAQ .......................... |GitGutterFAQ|

===============================================================================
1. INTRODUCTION                                         *GitGutterIntroduction*
                                                                    *GitGutter*

Vim Git Gutter is a Vim plugin which shows a git diff in the 'gutter' (sign
column). It shows whether each line has been added, modified, and where lines
have been removed.

This is a port of the Git Gutter plugin for Sublime Text 2.

===============================================================================
2. INSTALLATION                                         *GitGutterInstallation*

* Pathogen:
>
  cd ~/.vim/bundle
  git clone git://github.com/airblade/vim-gitgutter.git
<
* Voom:

Edit your plugin manifest (`voom edit`) and add:
>
  airblade/vim-gitgutter
<
* VimPlug:

Place this in your .vimrc:
>
    Plug 'airblade/vim-gitgutter'
<
Then run the following in Vim:
>
  :source %
  :PlugInstall
<
* NeoBundle:

Place this in your .vimrc:
>
  NeoBundle 'airblade/vim-gitgutter'
<
Then run the following in Vim:
>
  :source %
  :NeoBundleInstall
<
* No plugin manager:

Copy vim-gitgutter's subdirectories into your vim configuration directory:
>
  cd tmp && git clone git://github.com/airblade/vim-gitgutter.git
  cp vim-gitgutter/* ~/.vim/
<
See |add-global-plugin|.

===============================================================================
3. USAGE                                                       *GitGutterUsage*

You don't have to do anything: it just works.

===============================================================================
4. COMMANDS                                                 *GitGutterCommands*

Commands for turning Git Gutter on and off:

  :GitGutterDisable                                         *:GitGutterDisable*
      Explicitly turn Git Gutter off.

  :GitGutterEnable                                           *:GitGutterEnable*
      Explicitly turn Git Gutter on.

  :GitGutterToggle                                           *:GitGutterToggle*
      Explicitly turn Git Gutter on if it was off and vice versa.

  :GitGutter                                                       *:GitGutter*
      Update signs for the current buffer.

  :GitGutterAll                                                 *:GitGutterAll*
      Update signs across all buffers.

Commands for turning signs on and off (defaults to on):

  :GitGutterSignsEnable                                 *:GitGutterSignsEnable*
      Explicitly turn line signs on.

  :GitGutterSignsDisable                               *:GitGutterSignsDisable*
      Explicitly turn line signs off.

  :GitGutterSignsToggle                                 *:GitGutterSignsToggle*
      Explicitly turn line signs on if it was off and vice versa.

Commands for turning line highlighting on and off (defaults to off):

  :GitGutterLineHighlightsEnable               *:GitGutterLineHighlightsEnable*
      Explicitly turn line highlighting on.

  :GitGutterLineHighlightsDisable             *:GitGutterLineHighlightsDisable*
      Explicitly turn line highlighting off.

  :GitGutterLineHighlightsToggle               *:GitGutterLineHighlightsToggle*
      Explicitly turn line highlighting on if it was off and vice versa.

Commands for jumping between marked hunks:

  :GitGutterNextHunk                                       *:GitGutterNextHunk*
      Jump to the next marked hunk.  Takes a count.

  :GitGutterPrevHunk                                       *:GitGutterPrevHunk*
      Jump to the previous marked hunk.  Takes a count.

Commands for staging or undoing individual hunks:

  :GitGutterStageHunk                                     *:GitGutterStageHunk*
      Stage the hunk the cursor is in.

  :GitGutterUndoHunk                                       *:GitGutterUndoHunk*
      Undo the hunk the cursor is in.

  :GitGutterPreviewHunk                                 *:GitGutterPreviewHunk*
      Preview the hunk the cursor is in.

===============================================================================
5. AUTOCOMMAND                                               *GitGutterAutocmd*

After updating a buffer's signs vim-gitgutter fires a |User| |autocmd| with the
event GitGutter.  You can listen for this event, for example:
>
  autocmd User GitGutter call updateMyStatusLine()
<

===============================================================================
6. CUSTOMISATION                                       *GitGutterCustomisation*

You can customise:

- The sign column's colours
- The signs' colours and symbols
- Line highlights
- The base of the diff
- Extra arguments for git-diff
- Key mappings
- The grep executable used
- Whether or not vim-gitgutter is on initially (defaults to on)
- Whether or not signs are shown (defaults to yes)
- Whether or not line highlighting is on initially (defaults to off)
- Whether or not vim-gitgutter runs in realtime (defaults to yes)
- Whether or not vim-gitgutter runs eagerly (defaults to yes)
- Whether or not vim-gitgutter runs asynchronously (defaults to yes)

Please note that vim-gitgutter won't override any colours or highlights you've
set in your colorscheme.

SIGN COLUMN

By default vim-gitgutter will make the sign column look like the line number
column (i.e. the |hl-LineNr| highlight group).

To customise your sign column's background color, first tell vim-gitgutter to
leave it alone:
>
  let g:gitgutter_override_sign_column_highlight = 0
<

And then either update your colorscheme's |hlSignColumn| highlight group or set
it in your |vimrc|:

  Desired appearance                  Command ~
  Same as line number column          highlight clear SignColumn
  User-defined (terminal Vim)         highlight SignColumn ctermbg={whatever}
  User-defined (graphical Vim)        highlight SignColumn guibg={whatever}

SIGNS' COLOURS AND SYMBOLS

To customise the colours, set up the following highlight groups in your
colorscheme or |vimrc|:

>
  GitGutterAdd          " an added line
  GitGutterChange       " a changed line
  GitGutterDelete       " at least one removed line
  GitGutterChangeDelete " a changed line followed by at least one removed line
<

You can either set these with `highlight GitGutterAdd {key}={arg}...` or link
them to existing highlight groups with, say:
>
  highlight link GitGutterAdd DiffAdd
<

To customise the symbols, add the following to your |vimrc|:
>
  let g:gitgutter_sign_added = 'xx'
  let g:gitgutter_sign_modified = 'yy'
  let g:gitgutter_sign_removed = 'zz'
  let g:gitgutter_sign_modified_removed = 'ww'
<

LINE HIGHLIGHTS

Similarly to the signs' colours, set up the following highlight groups in your
colorscheme or |vimrc|:
>
  GitGutterAddLine          " default: links to DiffAdd
  GitGutterChangeLine       " default: links to DiffChange
  GitGutterDeleteLine       " default: links to DiffDelete
  GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault
<

THE BASE OF THE DIFF

By default buffers are diffed against the index.  To diff against a commit
instead:
>
  let g:gitgutter_diff_base = '<commit SHA>'
<

EXTRA ARGUMENTS FOR GIT-DIFF

To pass extra arguments to git-diff, add this to your |vimrc|:
>
  let g:gitgutter_diff_args = '-w'
<

KEY MAPPINGS

To disable all key maps:
>
  let g:gitgutter_map_keys = 0
<

To change the hunk-jumping maps (defaults shown):
>
  nmap [c <Plug>GitGutterPrevHunk
  nmap ]c <Plug>GitGutterNextHunk
<

To change the hunk-staging/undoing/previewing maps (defaults shown):
>
  nmap <Leader>hs <Plug>GitGutterStageHunk
  nmap <Leader>hu <Plug>GitGutterUndoHunk
  nmap <Leader>hp <Plug>GitGutterPreviewHunk
<

To change the hunk text object maps (defaults shown):
>
  omap ic <Plug>GitGutterTextObjectInnerPending
  omap ac <Plug>GitGutterTextObjectOuterPending
  xmap ic <Plug>GitGutterTextObjectInnerVisual
  xmap ac <Plug>GitGutterTextObjectOuterVisual
<

TO USE A CUSTOM GREP COMMAND

To use a custom invocation for grep, use this:
>
  let g:gitgutter_grep_command = 'grep --color=never -e'
<

TO TURN OFF VIM-GITGUTTER BY DEFAULT

Add to your |vimrc|
>
  let g:gitgutter_enabled = 0
<

TO TURN OFF SIGNS BY DEFAULT

Add to your |vimrc|
>
  let g:gitgutter_signs = 0
<

Note that the sign column will still be present if you have line highlighting
switched on.

TO TURN ON LINE HIGHLIGHTING BY DEFAULT

Add to your |vimrc|
>
  let g:gitgutter_highlight_lines = 1
<

TO STOP VIM-GITGUTTER RUNNING IN REALTIME

Add to your |vimrc|
>
  let g:gitgutter_realtime = 0
<

TO STOP VIM-GITGUTTER RUNNING EAGERLY

Add to your |vimrc|
>
  let g:gitgutter_eager = 0
<

TO TURN OFF ASYNCHRONOUS UPDATES

By default diffs are run asynchronously.  To run diffs synchronously
instead:

Add to your |vimrc|
>
let g:gitgutter_async = 0
<

===============================================================================
7. FAQ                                                           *GitGutterFAQ*

a. Why are the colours in the sign column weird?

  Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly.
  Please see |GitGutterCustomisation| on customising the sign column.

b. What happens if I also use another plugin which uses signs (e.g. Syntastic)?

  Vim only allows one sign per line. Before adding a sign to a line,
  vim-gitgutter checks whether a sign has already been added by somebody else.
  If so it doesn't do anything. In other words vim-gitgutter won't overwrite
  another plugin's signs. It also won't remove another plugin's signs.