Wikia

Vim Tips Wiki

Changes: Folding for diff files

Edit

Back to page

(Created page with "When you want to inspect large diff/patch files, following fold function may come handy. Put it in your ftplugin/diff.vim file or equivalent. <code> setlocal foldmethod=expr ...")
 
(Add Related plugins section with a link to diff_fold.vim.)
Line 13: Line 13:
 
endfunction
 
endfunction
 
</code>
 
</code>
  +
  +
==Related plugins==
  +
* {{script|id=3262|text=diff_fold.vim}} folds changesets, files, and hunks in (Mercurial, and similar) diff output.

Revision as of 15:26, June 24, 2013

When you want to inspect large diff/patch files, following fold function may come handy. Put it in your ftplugin/diff.vim file or equivalent.

setlocal foldmethod=expr foldexpr=DiffFold(v:lnum)
function! DiffFold(lnum)
    let line = getline(a:lnum)
    if line =~ '^\(diff\|---\|+++\|@@\) '
        return 1
    elseif line[0] =~ '[-+ ]'
        return 2
    else
        return 0
    endif
endfunction

Related plugins

  • diff_fold.vim folds changesets, files, and hunks in (Mercurial, and similar) diff output.

Around Wikia's network

Random Wiki