vimword-wrapvimdiff

Forcing vimdiff to wrap lines?


When diffing 2 files in VIM, I prefer the lines to be wrapped. However, vimdiff sets wrap to off by default.

Is there a way to set line wrap automatically for every diff?


Solution

  • I use the following:

    autocmd FilterWritePre * if &diff | setlocal wrap< | endif
    

    FilterWritePre is triggered immediately before a generated diff is written to the buffer, and setlocal wrap< copies the global value of wrap. Of course it's also possible to simply force setlocal wrap.