On 2024-10-02, flyingosprey wrote: > On Windows, I ran > > git config --global --replace-all merge.tool gvimdiff > git config --global --replace-all mergetool.gvimdiff.path "C:/Program > Files/Vim > /vim90/gvim.exe" > git config --global --replace-all mergetool.gvimdiff.trustExitCode false > git config --global --replace-all merge.conflictstyle diff3 > > to set gvim as git mergetool. > > I want to set a different color when git merge. I found > > if &diff > colorscheme codedark > endif > > does not work because when git merge starts, &diff is 0. > > Questions: In .vimrc, how to tell if gvim is under git 3way merge or not? > > Thanks for your suggestion.
The only way I use git on Windows is from Cygwin or from Git for Windows, so these comments apply to those environments. I'm surprised that "if &diff" doesn't work. In my ~/.gitconfig, the vimdiff mergetool is this: cmd = "vim -d -c '4wincmd w | wincmd J | wincmd =' $LOCAL $BASE $REMOTE $MERGED" The -d option sets &diff before .vimrc is sourced. A few ideas come to mind: 1. After git opens gvim, execute :echo $GIT<tab> to complete all the environment variables in gvim's environment that begin with "GIT". Alternatively, shell out, then look for those variable from the shell, e.g., :sh $ env | grep GIT See if any of those variable names or values are unique to the merge command. If some are, then test their existence and/or values in your .vimrc. 2. Wait to test the value of &diff until gvim is finished opening files, e.g., autocmd VimEnter if &diff | colorscheme codedark | endif That has the problem that it will set your colorscheme for any vimdiff command. 3. Expand the VimEnter autocommand above to either count the number of windows (winnr("$")) and check that the number is 4, or traverse the open windows and check that &diff is set in all of them. 4. Examine the v:argv variable and look for a pattern in the arguments that might be unique to the git merge command. HTH, Gary -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20241003205529.GG15474%40phoenix.