Created
August 13, 2016 12:24
-
-
Save romainl/481814c86dba39d32715ff77ec96c1ed to your computer and use it in GitHub Desktop.
Diff detection in vimscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" this should echo '1' when entering 'diff mode' and '0' otherwise | |
function! IsDiff(opt) | |
let isdiff = 0 | |
if v:progname =~ "diff" | |
let isdiff = isdiff + 1 | |
endif | |
if &diff == 1 | |
let isdiff = isdiff + 1 | |
endif | |
if a:opt =~ "scrollopt" | |
if &scrollopt =~ "hor" | |
let isdiff = isdiff + 1 | |
endif | |
endif | |
return isdiff | |
endfunction | |
autocmd! VimEnter,OptionSet * echom IsDiff(expand('<amatch>')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:help v:argv
should help, nowadays.