I’ve been reading some dotfiles (.vimrc .gvimrc) to learn some neat tricks, and I’ve come across this one:
if has("gui_running")
set fuoptions=maxvert,maxhorz
au GUIEnter * set fullscreen
endif
If this is already a .gvimrc (only loaded if gVim is loaded) why does it have the condition if has("gui_running")? Isn’t this redundant? Is there an special issue/reason for that?
I know that if has("gui_running") is interesting to use in scripts and such, I’m asking specifically for it’s uses in .gvimrc, because it’s only sourced when I use gvim, so in theory, is not needed.
The gvimrc file that the OP linked to was mine, so I had better own up and admit that it was done for no good reason.
I copied that snippet from Hacking without distractions, which recommends putting it in your vimrc. Then at some point I realized it would be neater to move it into the gvimrc file, but I didn’t think it through clearly and left the
if has('gui_running')check in place. You’re right to point out that it is unnecessary, so I have now removed it.For the sake of posterity, here’s my gvimrc before and after the change.