Wikia

Vim Tips Wiki

Folding for diff files

Talk0
1,612pages on
this wiki
Revision as of 15:12, June 24, 2013 by 213.29.225.26 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Around Wikia's network

Random Wiki