sponsor Vim development Vim logo Vim Book Ad

vim-diff-context : Grow and shrink the diff context ('diffopt' context:) with hotkeys

 script karma  Rating 0/0, Downloaded by 1  Comments, bugs, improvements  Vim wiki

created by
Illia Bobyr
 
script type
utility
 
description
In diff mode Vim folds unchanged lines, keeping a few lines of context around
each change.  The amount is the "context:" item of 'diffopt'.  This plugin
changes it with a keystroke, leaving the rest of 'diffopt' alone.

Default Normal mode bindings:

  <Leader>d+   increase the context ([count] steps at once)
  <Leader>d-   decrease the context (never below 0)
  <Leader>d=   reset the context to the default (6 lines)

A default binding is only created when its key is not already mapped, so
existing mappings are never overwritten.  Keys can be changed, or turned off,
with g:diff_context_increase_map, g:diff_context_decrease_map,
g:diff_context_reset_map and g:diff_context_no_mappings.  <Plug> mappings are
provided for mapping them yourself.

Also adds a command:

  :DiffContext        show the current context
  :DiffContext 10     set it to 10 lines
  :DiffContext +3     increase by 3
  :DiffContext -3     decrease by 3

See :help diff-context for all options.

Development happens on GitHub; issues and pull requests are welcome there:
https://github.com/illia-bobyr/vim-diff-context
 
install details
Unzip into a package directory, so it loads on startup:

  mkdir -p ~/.vim/pack/plugins/start
  cd ~/.vim/pack/plugins/start
  unzip /path/to/vim-diff-context-1.0.zip

Then generate the help tags once, from inside Vim:

  :helptags ~/.vim/pack/plugins/start/vim-diff-context/doc

With a plugin manager, use the GitHub repository instead, e.g. vim-plug:

  Plug 'illia-bobyr/vim-diff-context'
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-diff-context-1.0.zip 1.0 2026-11-14 9.0 Illia Bobyr Initial upload
ip used for rating: 216.73.216.164

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github