Wikia

Vim Tips Wiki

Folding for diff files

Talk0
1,610pages on
this wiki
Revision as of 15:26, June 24, 2013 by Inkarkat (Talk | contribs)

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.
Advertisement | Your ad here

Around Wikia's network

Random Wiki