" ============================================================================ " File: gundo.vim " Description: vim global plugin to visualizer your undo tree " Maintainer: Steve Losh " License: GPLv2+ -- look it up. " Notes: Much of this code was thiefed from Mercurial, and the rest was " heavily inspired by scratch.vim and histwin.vim. " " ============================================================================ "{{{ Init "if exists('loaded_gundo') || &cp "finish "endif "let loaded_gundo = 1 if !exists('g:gundo_width') let g:gundo_width = 45 endif "}}} "{{{ Movement Mappings function! s:GundoMoveUp() if line('.') - 2 <= 4 return endif call cursor(line('.') - 2, 0) let line = getline('.') let idx1 = stridx(line, '@') let idx2 = stridx(line, 'o') if idx1 != -1 call cursor(0, idx1 + 1) else call cursor(0, idx2 + 1) endif let target_line = matchstr(getline("."), '\v\[[0-9]+\]') let target_num = matchstr(target_line, '\v[0-9]+') call s:GundoRenderPreview(target_num) endfunction function! s:GundoMoveDown() if line('.') + 2 >= line('$') return endif call cursor(line('.') + 2, 0) let line = getline('.') let idx1 = stridx(line, '@') let idx2 = stridx(line, 'o') if idx1 != -1 call cursor(0, idx1 + 1) else call cursor(0, idx2 + 1) endif let target_line = matchstr(getline("."), '\v\[[0-9]+\]') let target_num = matchstr(target_line, '\v[0-9]+') call s:GundoRenderPreview(target_num) endfunction "}}} "{{{ Buffer/Window Management function! s:GundoResizeBuffers(backto) exe bufwinnr(bufwinnr('__Gundo__')) . "wincmd w" exe "vertical resize " . g:gundo_width exe bufwinnr(bufwinnr('__Gundo_Preview__')) . "wincmd w" exe "vertical resize " . 40 exe a:backto . "wincmd w" endfunction function! s:GundoOpenBuffer() let existing_gundo_buffer = bufnr("__Gundo__") if existing_gundo_buffer == -1 exe "vnew __Gundo__" wincmd H call s:GundoResizeBuffers(winnr()) nnoremap