I'm trying to add a conditional to my vimrc file testing if number (line numbers) option is set. I have :number added only with HTML file type,
:autocmd FileType html source $HOME/.vim/html_vimrc.vim
:if ('&number' == 0) "IF number is off
: set spell "turn on spell checker
:else "ELSE file type is HTML
: set nospell "turn spell checker off
:endif
I've tried,
:if (&number == "number")
:if $number
I've tried with parentheses, quotes, no quotes. All my tests either set spell for all or none. I'm reading the VIMDOCS on conditionals, but I'm not getting something right and I can't find a similar example.
Update: In addition to testing Michael's code below, I've simplified the test with the following in vimrc:
:if exists("g:prog")
: set number "trying a different setting
:endif
And in the FileType loaded html_vimrc file I have,
"number "turned this off
:let g:prog=1
In this situation the test case of test.html the g:prog is set but "number" is not. In the test.vim case g:prog is not set and "number" is not. This seems to suggest there is some fundamental logic to how VIM handles loaded vimrc files that I am missing.