Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

question from:https://stackoverflow.com/questions/4229658/why-some-people-use-if-hasgui-running-in-a-gvimrc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
293 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...