diff options
author | Teddy Wing | 2019-10-27 00:57:22 +0200 |
---|---|---|
committer | Teddy Wing | 2019-10-27 22:09:26 +0100 |
commit | d8607bc48b1313b9acdf03d0c80e47fdbf1ba6c6 (patch) | |
tree | 12ff8f8c1ec316084f8d0b2c7a919efa12125c8a | |
parent | f5ca8380ee0596916ec19503b4546c899c51d12c (diff) | |
download | dotvim-d8607bc48b1313b9acdf03d0c80e47fdbf1ba6c6.tar.bz2 |
Add 'git-shortcuts' plugin
An ftplugin that provides `[[` and `]]` mappings to move between commits
in `git log` output.
-rw-r--r-- | bundle/git-shortcuts/autoload/git_shortcuts.vim | 10 | ||||
-rw-r--r-- | bundle/git-shortcuts/ftplugin/git/git_shortcuts.vim | 18 |
2 files changed, 28 insertions, 0 deletions
diff --git a/bundle/git-shortcuts/autoload/git_shortcuts.vim b/bundle/git-shortcuts/autoload/git_shortcuts.vim new file mode 100644 index 0000000..bcd32d9 --- /dev/null +++ b/bundle/git-shortcuts/autoload/git_shortcuts.vim @@ -0,0 +1,10 @@ +let s:COMMIT_START_PATTERN = '^commit' + + +function! git_shortcuts#CommitBackward() + call search(s:COMMIT_START_PATTERN, 'b') +endfunction + +function! git_shortcuts#CommitForward() + call search(s:COMMIT_START_PATTERN) +endfunction diff --git a/bundle/git-shortcuts/ftplugin/git/git_shortcuts.vim b/bundle/git-shortcuts/ftplugin/git/git_shortcuts.vim new file mode 100644 index 0000000..1c844b7 --- /dev/null +++ b/bundle/git-shortcuts/ftplugin/git/git_shortcuts.vim @@ -0,0 +1,18 @@ +if exists('g:no_plugin_maps') || exists('g:no_git_shortcut_maps') + finish +endif + +let b:undo_ftplugin = '' + +if !hasmapto('<Plug>GitShortcutsCommitBackward') + nmap <buffer> [[ <Plug>GitShortcutsCommitBackward + let b:undo_ftplugin .= '| nunmap <buffer> [[' +endif + +if !hasmapto('<Plug>GitShortcutsCommitForward') + nmap <buffer> ]] <Plug>GitShortcutsCommitForward + let b:undo_ftplugin .= '| nunmap <buffer> ]]' +endif + +nnoremap <buffer> <Plug>GitShortcutsCommitBackward :call git_shortcuts#CommitBackward()<CR> +nnoremap <buffer> <Plug>GitShortcutsCommitForward :call git_shortcuts#CommitForward()<CR> |