1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-16 06:47:52 +01:00
vim/runtime/ftplugin/gitrebase.vim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.7 KiB
VimL
Raw Normal View History

2008-06-24 22:58:06 +00:00
" Vim filetype plugin
" Language: git rebase --interactive
2010-01-06 20:54:52 +01:00
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
2022-01-08 21:51:59 +00:00
" Last Change: 2022 Jan 05
2008-06-24 22:58:06 +00:00
" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
2010-05-21 12:05:36 +02:00
finish
2008-06-24 22:58:06 +00:00
endif
let b:did_ftplugin = 1
2022-01-08 21:51:59 +00:00
let &l:comments = ':' . (matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0]
let &l:commentstring = &l:comments[1] . ' %s'
setlocal formatoptions-=t
setlocal nomodeline
2022-01-08 21:51:59 +00:00
let b:undo_ftplugin = "setl com< cms< fo< ml<"
2008-06-24 22:58:06 +00:00
2019-12-05 22:47:25 +01:00
function! s:choose(word) abort
2010-05-21 12:05:36 +02:00
s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e
2008-06-24 22:58:06 +00:00
endfunction
2019-12-05 22:47:25 +01:00
function! s:cycle(count) abort
let words = ['pick', 'edit', 'fixup', 'squash', 'reword', 'drop']
let index = index(map(copy(words), 'v:val[0]'), getline('.')[0])
let index = ((index < 0 ? 0 : index) + 10000 * len(words) + a:count) % len(words)
call s:choose(words[index])
2008-06-24 22:58:06 +00:00
endfunction
2019-12-05 22:47:25 +01:00
command! -buffer -bar -range Pick :<line1>,<line2>call s:choose('pick')
command! -buffer -bar -range Squash :<line1>,<line2>call s:choose('squash')
command! -buffer -bar -range Edit :<line1>,<line2>call s:choose('edit')
command! -buffer -bar -range Reword :<line1>,<line2>call s:choose('reword')
command! -buffer -bar -range Fixup :<line1>,<line2>call s:choose('fixup')
command! -buffer -bar -range Drop :<line1>,<line2>call s:choose('drop')
command! -buffer -count=1 -bar -bang Cycle call s:cycle(<bang>0 ? -<count> : <count>)
2008-06-24 22:58:06 +00:00
if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps")
2010-05-21 12:05:36 +02:00
finish
2008-06-24 22:58:06 +00:00
endif
2019-12-05 22:47:25 +01:00
nnoremap <buffer> <silent> <C-A> :<C-U><C-R>=v:count1<CR>Cycle<CR>
nnoremap <buffer> <silent> <C-X> :<C-U><C-R>=v:count1<CR>Cycle!<CR>
2008-06-24 22:58:06 +00:00
2022-01-08 21:51:59 +00:00
let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap <buffer> <C-A>'|exe 'nunmap <buffer> <C-X>'"