Skip to content

Commit

Permalink
Initial stab at SCM conflict jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Dec 7, 2011
1 parent 440629a commit 8505f2e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/unimpaired.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ is "args" and for the "q" commands is "quickfix".
]o Go to the file succeeding the current one
alphabetically in the current file's directory.

*[n*
]n Go to the previous SCM conflict marker. Try d[n
inside a conflict.

*]n*
]n Go to the next SCM conflict marker. Try d]n inside a
conflict.

LINE OPERATIONS *unimpaired-lines*

*[<Space>*
Expand Down
47 changes: 47 additions & 0 deletions plugin/unimpaired.vim
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,53 @@ nnoremap <silent> <Plug>unimpairedOPrevious :<C-U>edit `=<SID>FileByOffset(-v:co
nmap ]o <Plug>unimpairedONext
nmap [o <Plug>unimpairedOPrevious
" }}}1
" Diff {{{1

nmap [n <Plug>unimpairedContextPrevious
nmap ]n <Plug>unimpairedContextNext
omap [n <Plug>unimpairedContextPrevious
omap ]n <Plug>unimpairedContextNext
nnoremap <silent> <Plug>unimpairedContextPrevious :call <SID>Context(1)<CR>
nnoremap <silent> <Plug>unimpairedContextNext :call <SID>Context(0)<CR>
onoremap <silent> <Plug>unimpairedContextPrevious :call <SID>ContextMotion(1)<CR>
onoremap <silent> <Plug>unimpairedContextNext :call <SID>ContextMotion(0)<CR>
function! s:Context(reverse)
call search('^@@ .* @@\|^[<=>|]\{7}[<=>|]\@!', a:reverse ? 'bW' : 'W')
endfunction

function! s:ContextMotion(reverse)
if a:reverse
-
endif
call search('^@@ .* @@\|^diff \|^[<=>|]\{7}[<=>|]\@!', 'bWc')
if getline('.') =~# '^diff '
let end = search('^diff ', 'Wn') - 1
if end < 0
let end = line('$')
endif
elseif getline('.') =~# '^@@ '
let end = search('^@@ .* @@\|^diff ', 'Wn') - 1
if end < 0
let end = line('$')
endif
elseif getline('.') =~# '^=\{7\}'
+
let end = search('^>\{7}>\@!', 'Wnc')
elseif getline('.') =~# '^[<=>|]\{7\}'
let end = search('^[<=>|]\{7}[<=>|]\@!', 'Wn') - 1
else
return
endif
if end > line('.')
execute 'normal! V'.(end - line('.')).'j'
elseif end == line('.')
normal! V
endif
endfunction

" }}}1
" Line operations {{{1

Expand Down

0 comments on commit 8505f2e

Please sign in to comment.