Vim Tips Wiki
Register
Advertisement

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created June 24, 2013 · complexity basic · version 7.0

When inspecting large diff/patch files, the following fold function is 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

Comments[]

Advertisement