Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch between diffchar and the default diff method without restarting vimdiff #33

Open
drrossum opened this issue Mar 10, 2023 · 9 comments

Comments

@drrossum
Copy link

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?

@rickhowe
Copy link
Owner

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

@drrossum
Copy link
Author

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?

@rickhowe
Copy link
Owner

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

@drrossum
Copy link
Author

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!

@rickhowe
Copy link
Owner

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

@drrossum drrossum changed the title make diffchar optional only switch between diffchar and the default diff method without restarting vimdiff Mar 13, 2023
@drrossum drrossum changed the title switch between diffchar and the default diff method without restarting vimdiff Switch between diffchar and the default diff method without restarting vimdiff Mar 13, 2023
@drrossum
Copy link
Author

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

@rickhowe
Copy link
Owner

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.

@drrossum
Copy link
Author

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

@rickhowe
Copy link
Owner

Hi, is it possible close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants