4

I am a new to Vim and know little about programming. The situation is this: I have both Vim and Gvim installed. From within Vim I think I have been able to use the :e $MYVIMRC command to do some edits I saw online. I was able to save it I think. I think so because the instructions I added show up when I open up Vim. However, now I want to also change the Vimrc for things related to my GVim (in particular I want to use GVim to to take advantage of python support). Here's where the weirdness happens for me. I try and use :e $MYVIMRC but when I open it up

  • The vimrc file does not reflect any changes that I made from within Vim.
  • The GVim program does not allow me to write to it. In fact, when I search for my vimrc file in my computer, I see only one file and it looks like the one that opens up in GVim only.

I'd like to understand:

  1. Why it appears I have to vimrc files though both programs echo back the same location
  2. How I can make changes to the vimrc file from the vantage point of GVim.

I have searched the site but couldn't resolve it myself. Thank you for any help/tips.

8
  • 1
    You should be able to use the same file for both, but you can specify one to use for just gVim by naming it .gvimrc. Just to be clear: you've tried :echo $MYVIMRC in both Vim and gVim and they give the same result?
    – Tumbler41
    Commented Apr 17, 2017 at 15:46
  • Hi Tumbler41. Yes when I echoed they both return the same place.
    – Jmaff
    Commented Apr 17, 2017 at 16:10
  • What's the location that's being reported for both? Also, your post states you're using :e $MYVIMRC$ (with a trailing $) but it should just be :e $MYVIMRC.
    – jamessan
    Commented Apr 17, 2017 at 18:07
  • 2
    As a side note, gVim (and I think vim as well) will need to be run as administrator to make changes to that location. I usually keep mine in C:\Users\user\.vimrc for that reason.
    – Tumbler41
    Commented Apr 17, 2017 at 19:50
  • 1
    Don't bother copying all the vim files over. You only need to copy the vimrc.
    – Tumbler41
    Commented Apr 17, 2017 at 20:23

2 Answers 2

3

The .vimrc is sourced from both Vim & Gvim. This file will allow you to set up a common set of CLI & GUI plugins in a single location (shared by both the CLI Vim & Gvim)

The .gvimrc is used by Gvim only and will be sourced by Gvim only after the .vimrc. Regular command line Vim won't read from it.

Within Gvim, you can edit the .vimrc file if you want changes to appear to all instances of Vim, or if it's Gvim specific you should be able to edit the .gvimrc file separately (to change menus or whatever else the GUI allows you to change)

:help gvimrc should provide some more insight.

Related: https://stackoverflow.com/a/38353317/2892779

9

The best way to find out, which files are loaded is to use the command :version

You may also have secondary rc files, which are being sourced. They will be displayed here. You will also see, which version of vim you have.

In addition :scriptnames will list all scripts in the order they are loaded, this is probably not what you want and will also include plugin scripts, etc.

What strikes me as odd, is that on windows, you usually have a _vimrc or _gvimrc (_ instead of .) and the default directory for these is %USERPROFILE%\vimfiles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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