In my vimrc I have <C-H>, <C-J>, <C-K> and <C-L> mapped to navigate between split windows in normal mode.  When I use diff mode I only ever have windows in vertical splits, so I'd like to re-purpose <C-J> and <C-K> to jump to the previous/next diff.:help diff mentions &diff when using vimdiff to determine whether you are in diff mode.  It looks like this also gets set when you start a diff from an existing vim session, so I assume I should leverage this somehow to re-set the mappings, but I'm not exactly sure how.  Based on my 2 second test just before posting this, I tried checking &diff in my vimrc and performing the mapping as needed, but as I suspected the vimrc doesn't get read in again when going into diff mode from an existing vim session.What would be the best way to detect going to/from diff mode and re-setting the mappings accordingly?
Create mappings that only apply to diff mode
key bindings;vimdiff
You can create an expression mapping that checks &diff. This is done using the <expr> keyword.Examplennoremap <expr> <C-J> &diff ? ']c' : '<C-W>j'With this, each time you type <C-J>, the expression &diff ? ']c' : '<C-W>h' is evaluated, and the result (a string) is used for your map. So, in diff-mode, <C-J> will be like ]c (jump to start of next change); otherwise, it will be like <C-W>j (move to window below).