3

I have gvim installed as well as vim. I want gvim and vim to share the same config file. How can I do that?

  • 10
    They should, already. Where are your config files located? – muru Feb 20 '17 at 3:20
  • they already do, .gvimrc usually contains additional settings that are gvim specific. .vimrc still remains the main config file – AnonymousLurker Dec 8 '18 at 15:13
5

Vim reads ~/.vimrc; gvim reads ~/.gvimrc as well as ~/.vimrc.

So simply put your commands into ~/.vimrc (and put the GUI-specific commands into ~/.gvimrc).

Newer Vims also look at ~/.vim/vimrc and ~/.vim/gvimrc.

  • 3
    its ~/.vim/vimrc and ~/.vim/gvimrc – Christian Brabandt Feb 21 '17 at 18:41
  • yes, true. details can be found by typing :he vimrc in vim – Naumann Feb 22 '17 at 14:59
5

You can also use something along the following lines in your vimrc:

if has('gui')
    set foo=bar
    ...
endif
3

has('gui') return True if Vim has a GUI compiled in (regardless of whether you're running the terminal vim or not). A better option is has('gui_running'), which only returns True if the GUI is actually running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.