gitrebase.vim 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. " Vim filetype plugin
  2. " Language: git rebase --interactive
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " Last Change: 2016 Aug 29
  5. " Only do this when not done yet for this buffer
  6. if (exists("b:did_ftplugin"))
  7. finish
  8. endif
  9. runtime! ftplugin/git.vim
  10. let b:did_ftplugin = 1
  11. setlocal comments=:# commentstring=#\ %s formatoptions-=t
  12. setlocal nomodeline
  13. if !exists("b:undo_ftplugin")
  14. let b:undo_ftplugin = ""
  15. endif
  16. let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<"
  17. function! s:choose(word)
  18. s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
  19. endfunction
  20. function! s:cycle()
  21. call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick'))
  22. endfunction
  23. command! -buffer -bar Pick :call s:choose('pick')
  24. command! -buffer -bar Squash :call s:choose('squash')
  25. command! -buffer -bar Edit :call s:choose('edit')
  26. command! -buffer -bar Reword :call s:choose('reword')
  27. command! -buffer -bar Fixup :call s:choose('fixup')
  28. command! -buffer -bar Cycle :call s:cycle()
  29. " The above are more useful when they are mapped; for example:
  30. "nnoremap <buffer> <silent> S :Cycle<CR>
  31. if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
  32. finish
  33. endif
  34. nnoremap <buffer> <expr> K col('.') < 7 && expand('<Lt>cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K'
  35. let b:undo_ftplugin = b:undo_ftplugin . "|nunmap <buffer> K"