Add commands for convenience.

This commit is contained in:
Andy Stewart
2013-02-28 10:08:06 +01:00
parent 3ab2f38fbe
commit cd818c9d8e
2 changed files with 17 additions and 8 deletions

View File

@@ -34,20 +34,20 @@ If you want vim-gitgutter off by default, add `let g:gitgutter_enabled = 0` to y
You can explicitly turn vim-gitgutter off and on: You can explicitly turn vim-gitgutter off and on:
* turn off with `:call DisableGitGutter()` * turn off with `:DisableGitGutter`
* turn on with `:call EnableGitGutter()` * turn on with `:EnableGitGutter`
* toggle with `:call ToggleGitGutter()`. * toggle with `:ToggleGitGutter`.
And you can turn line highlighting on and off (defaults to off): And you can turn line highlighting on and off (defaults to off):
* turn on with `:call EnableGitGutterLineHighlights()` * turn on with `:EnableGitGutterLineHighlights`
* turn off with `:call DisableGitGutterLineHighlights()` * turn off with `:DisableGitGutterLineHighlights`
* toggle with `:call ToggleGitGutterLineHighlights()`. * toggle with `:ToggleGitGutterLineHighlights`.
Furthermore you can jump between hunks: Furthermore you can jump between hunks:
* jump to next hunk: `:call GitGutterNextHunk()` * jump to next hunk: `:GitGutterNextHunk`
* jump to previous hunk: `:call GitGutterPrevHunk()`. * jump to previous hunk: `:GitGutterPrevHunk`.
You may want to add mappings for these if you use them often. You may want to add mappings for these if you use them often.

View File

@@ -249,16 +249,19 @@ function! GitGutter()
call s:show_signs(file_name, modified_lines) call s:show_signs(file_name, modified_lines)
endif endif
endfunction endfunction
command GitGutter call GitGutter()
function! DisableGitGutter() function! DisableGitGutter()
let g:gitgutter_enabled = 0 let g:gitgutter_enabled = 0
call s:clear_signs(s:current_file()) call s:clear_signs(s:current_file())
endfunction endfunction
command DisableGitGutter call DisableGitGutter()
function! EnableGitGutter() function! EnableGitGutter()
let g:gitgutter_enabled = 1 let g:gitgutter_enabled = 1
call GitGutter() call GitGutter()
endfunction endfunction
command EnableGitGutter call EnableGitGutter()
function! ToggleGitGutter() function! ToggleGitGutter()
if g:gitgutter_enabled if g:gitgutter_enabled
@@ -267,18 +270,22 @@ function! ToggleGitGutter()
call EnableGitGutter() call EnableGitGutter()
endif endif
endfunction endfunction
command ToggleGitGutter call ToggleGitGutter()
function! DisableGitGutterLineHighlights() function! DisableGitGutterLineHighlights()
call s:update_line_highlights(0) call s:update_line_highlights(0)
endfunction endfunction
command DisableGitGutterLineHighlights call DisableGitGutterLineHighlights()
function! EnableGitGutterLineHighlights() function! EnableGitGutterLineHighlights()
call s:update_line_highlights(1) call s:update_line_highlights(1)
endfunction endfunction
command EnableGitGutterLineHighlights call EnableGitGutterLineHighlights()
function! ToggleGitGutterLineHighlights() function! ToggleGitGutterLineHighlights()
call s:update_line_highlights(s:highlight_lines ? 0 : 1) call s:update_line_highlights(s:highlight_lines ? 0 : 1)
endfunction endfunction
command ToggleGitGutterLineHighlights call ToggleGitGutterLineHighlights()
function! GitGutterNextHunk() function! GitGutterNextHunk()
if s:is_active() if s:is_active()
@@ -291,6 +298,7 @@ function! GitGutterNextHunk()
endfor endfor
endif endif
endfunction endfunction
command GitGutterNextHunk call GitGutterNextHunk()
function! GitGutterPrevHunk() function! GitGutterPrevHunk()
if s:is_active() if s:is_active()
@@ -303,6 +311,7 @@ function! GitGutterPrevHunk()
endfor endfor
endif endif
endfunction endfunction
command GitGutterPrevHunk call GitGutterPrevHunk()
augroup gitgutter augroup gitgutter
autocmd! autocmd!