diffchar.vim icon indicating copy to clipboard operation
diffchar.vim copied to clipboard

Switch between diffchar and the default diff method without restarting vimdiff

Open drrossum opened this issue 2 years ago • 9 comments

This is exactly my question, but the answer is outdated: https://stackoverflow.com/questions/28407691/vim-disable-plugin-by-default-diffchar

In vim8, I put this plugin in the ~/.vim/.../opt/ folder. Then, how do I enable the plugin when I'm looking at the two files in vimdiff?

drrossum avatar Mar 10 '23 22:03 drrossum

How about using packadd command to load the plugin? Or you could locate the plugin in .../start/ folder. g:DiffExpr is not used now.

rickhowe avatar Mar 11 '23 05:03 rickhowe

I put the plugin in the opt folder, start vimdiff on two files, type packadd. I now still see the normal (non-diffchar) diff result.

What what command do I issue now to see the diffchar diffs?

drrossum avatar Mar 11 '23 13:03 drrossum

If you locate the plugin in opt folder, it is not loaded at vim startup. You can use -c 'packadd diffchar' option or add 'packadd diffchar' in your vimrc. If possible, it might be better to locate them in start folder so that it is automatically loaded at sartup

rickhowe avatar Mar 11 '23 15:03 rickhowe

Starting vimdiff with -c 'packadd diffchar.vim' on the command line works. Thank you!

Out of curiosity: would you know a way to load and activate the plugin after vimdiff has started? I mean, without quitting vimdiff and starting vimdiff again using the CLI option above? It would be a very useful feature to be able to toggle!

drrossum avatar Mar 13 '23 10:03 drrossum

You can use diffthis and diffoff commands on any windows, Check to see :help diff.

rickhowe avatar Mar 13 '23 10:03 rickhowe

The feature I'm interested in is maybe better described as: "switch between diffchar and the default diff method without restarting vimdiff".

I updated the title to hopefully be more descriptive

drrossum avatar Mar 13 '23 10:03 drrossum

I see you want to toggle diff mode windows between with and without diffchar plugin. This is a kind of a private option, but if you set 1 to g:NoDiffChar variable, the plugin does nothing. Try to set 0 or 1 to the variable after or before diffthis and diffoff.

rickhowe avatar Mar 13 '23 13:03 rickhowe

cool! I'll use a function to do this:

let g:NoDiffChar=1
function! DiffToggle()
    let g:NoDiffChar = g:NoDiffChar? 0: 1
    diffoff | diffthis
endfunction

drrossum avatar Mar 13 '23 16:03 drrossum

Hi, is it possible close this issue?

rickhowe avatar Jul 13 '23 01:07 rickhowe