[patch] Store vimrc and gvimrc in your ~/.vim, ~\vimfiles\ directory

142 views
Skip to first unread message

Lech Lorens

unread,
Apr 12, 2013, 4:54:39 AM4/12/13
to vim_dev
The attached patch makes it possible to move the vimrc and gvimrc files
to your vim settings directory:
~/.vim/ (UNIX)
~\vimfiles\ (Windows)

etc. This makes it easier to move Vim settings from machine to machine:
you just copy one directory to the right place and it works.

Please, check and apply.

--
Cheers,
Lech
vimrc-in-vimfiles.patch

Bram Moolenaar

unread,
Apr 12, 2013, 7:45:32 AM4/12/13
to Lech Lorens, vim_dev

Lech Lorens wrote:

> The attached patch makes it possible to move the vimrc and gvimrc files
> to your vim settings directory:
> ~/.vim/ (UNIX)
> ~\vimfiles\ (Windows)

True.

> etc. This makes it easier to move Vim settings from machine to machine:
> you just copy one directory to the right place and it works.
>
> Please, check and apply.

The updated docs say:
Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
Unix $HOME/.vimrc or $HOME/.vim/vimrc

What does that "or" mean? What if both files exist?

This is an important thing, where your Vim settings are located. This
deserves proper explanation, also for beginners.


--
hundred-and-one symptoms of being an internet addict:
152. You find yourself falling for someone you've never seen or hardly
know, but, boy can he/she TYPE!!!!!!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Lech Lorens

unread,
Apr 12, 2013, 9:29:32 AM4/12/13
to vim_dev

On 12 April 2013 13:45, Bram Moolenaar <Br...@moolenaar.net> wrote:

The updated docs say:
        Unix                $HOME/.gvimrc or $HOME/.vim/gvimrc
        Unix                $HOME/.vimrc or $HOME/.vim/vimrc

What does that "or" mean?  What if both files exist?

This is an important thing, where your Vim settings are located.  This
deserves proper explanation, also for beginners.

OK, I'll update the docs. BTW the docs do not mention the values for VMS. Would you like to have them added as well?

--
Cheers,
Lech

Bram Moolenaar

unread,
Apr 12, 2013, 11:03:29 AM4/12/13
to Lech Lorens, vim_dev
Yes. Or we can send an email to the VMS user. :-)

--
hundred-and-one symptoms of being an internet addict:
157. You fum through a magazine, you first check to see if it has a web
address.

Gary Johnson

unread,
Apr 12, 2013, 1:51:06 PM4/12/13
to vim_dev
On 2013-04-12, Lech Lorens wrote:
>
> On 12 April 2013 13:45, Bram Moolenaar wrote:
>
>
> The updated docs say:
> Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
> Unix $HOME/.vimrc or $HOME/.vim/vimrc
>
> What does that "or" mean? What if both files exist?
>
> This is an important thing, where your Vim settings are located. This
> deserves proper explanation, also for beginners.
>
>
> OK, I'll update the docs.

":help .vimrc" will need to be updated as well.

Nice addition.

Regards,
Gary

Lech Lorens

unread,
Apr 13, 2013, 8:08:21 AM4/13/13
to Bram Moolenaar, vim_dev
On 12-Apr-2013 Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> Lech Lorens wrote:
>
> > On 12 April 2013 13:45, Bram Moolenaar <Br...@moolenaar.net> wrote:
> >
> > >
> > > The updated docs say:
> > > Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
> > > Unix $HOME/.vimrc or $HOME/.vim/vimrc
> > >
> > > What does that "or" mean? What if both files exist?
> > >
> > > This is an important thing, where your Vim settings are located. This
> > > deserves proper explanation, also for beginners.
> > >
> >
> > OK, I'll update the docs. BTW the docs do not mention the values for VMS.
> > Would you like to have them added as well?
>
> Yes. Or we can send an email to the VMS user. :-)

Oh, I didn't realise there were so many of them :-)
I added a note about the order in which the vimrc/gvimrc files are
searched and which one of them is actually sourced. I didn't add the
note for VMS.

--
Cheers,
Lech
vimrc-in-vimfiles.patch

Lech Lorens

unread,
Apr 13, 2013, 8:14:45 AM4/13/13
to vim_dev
Thanks for the reminder!

> Nice addition.

Good to know someone will find it useful.

--
Cheers,
Lech

Bram Moolenaar

unread,
Apr 13, 2013, 8:20:32 AM4/13/13
to Lech Lorens, vim_dev
Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
be used. That should work for places where a new Vim is installed. For
older Vim versions one would have to create a ~/.vimrc file that sources
~/.vim/vimrc.

Is there anything else for Vim configuration that is outside of ~/.vim?

--
hundred-and-one symptoms of being an internet addict:
164. You got out to buy software, instead of going out for a beer.

Lech Lorens

unread,
Apr 14, 2013, 4:29:53 PM4/14/13
to Bram Moolenaar, vim_dev
On 13-Apr-2013 Bram Moolenaar <Br...@moolenaar.net> wrote:
> Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
> be used. That should work for places where a new Vim is installed. For
> older Vim versions one would have to create a ~/.vimrc file that sources
> ~/.vim/vimrc.

Do we want to change the priority? I meant not to confuse people if by
any chance they have both ~/.vimrc and ~/.vim/vimrc.

>
> Is there anything else for Vim configuration that is outside of ~/.vim?

AFAIK the location of all the other stuff can be controlled by one or
another setting.

--
Cheers,
Lech

Gary Johnson

unread,
Apr 14, 2013, 5:25:06 PM4/14/13
to vim_dev, Bram Moolenaar
On 2013-04-14, Lech Lorens wrote:
> On 13-Apr-2013 Bram Moolenaar wrote:
> > Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
> > be used. That should work for places where a new Vim is installed. For
> > older Vim versions one would have to create a ~/.vimrc file that sources
> > ~/.vim/vimrc.

I don't understand. If you have an older Vim version, the user is
already using ~/.vimrc and that Vim will never look for
~/.vim/vimrc.

> Do we want to change the priority? I meant not to confuse people if by
> any chance they have both ~/.vimrc and ~/.vim/vimrc.

No. I was initially concerned about this patch, but the priority
you chose is perfect for my several Vim installations that share a
common ~/.vim or ~/vimfiles.

I already have a ~/.vim/vimrc file that I symlink to ~/.vim on Unix
and source from ~/_vimrc on Windows. With your patch, I can keep
these installations the same or eliminate the ~/.vimrc and ~/_vimrc
files.

For those installations where I want to customize my configuration,
or experiment with my configuration before imposing it on all my
other installations, I copy ~/.vim/vimrc to ~/.vimrc (or to ~/_vimrc
on Windows) and modify the copy. Again, this works with or without
your patch.

If a user has both ~/.vim and ~/.vim/vimrc, ~/.vimrc should have
priority. I can't think of a scenario where it would be
advantageous to give priority to ~/.vim/vimrc.

Regards,
Gary

Tony Mechelynck

unread,
Apr 14, 2013, 6:17:50 PM4/14/13
to vim...@googlegroups.com
On 14/04/13 23:25, Gary Johnson wrote:
> On 2013-04-14, Lech Lorens wrote:
>> On 13-Apr-2013 Bram Moolenaar wrote:
>>> Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
>>> be used. That should work for places where a new Vim is installed. For
>>> older Vim versions one would have to create a ~/.vimrc file that sources
>>> ~/.vim/vimrc.
>
> I don't understand. If you have an older Vim version, the user is
> already using ~/.vimrc and that Vim will never look for
> ~/.vim/vimrc.
[...]

Precisely. If you want to keep your vimrc under ~/.vim/ (unix) or
~/vimfiles/ (Windows) and use it even with older versions of Vim, you
will need to source it from a vimrc placed at the usual place. Note that
Unix Vim wil search for ~/_vimrc if it doesn't find ~/.vimrc, and
Windows Vim will search for ~/.vimrc and $VIM/_vimrc (and maybe even
$VIM/.vimrc) if it doesn't find ~/_vimrc. This is your "user" vimrc, it
is searched for after the "system" vimrc, which has neither . nor _ in
its name, and is by default at $VIM/vimrc, but often at /etc/vimrc in
versions of Vim shipped with Linux distributions.


Best regards,
Tony.
--
You will be attacked by a beast who has the body of a wolf, the tail of
a lion, and the face of Donald Duck.

Bram Moolenaar

unread,
Apr 15, 2013, 7:49:57 AM4/15/13
to Lech Lorens, vim_dev

Lech Lorens wrote:

> On 13-Apr-2013 Bram Moolenaar <Br...@moolenaar.net> wrote:
> > Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
> > be used. That should work for places where a new Vim is installed. For
> > older Vim versions one would have to create a ~/.vimrc file that sources
> > ~/.vim/vimrc.
>
> Do we want to change the priority? I meant not to confuse people if by
> any chance they have both ~/.vimrc and ~/.vim/vimrc.

In my opinion, when a user sees a ~/.vimrc he expects it to be used and
would be very surprised when it is skipped. That is both for existing
Vim users and any generic Unix user. Far fewer people would know about
the possibility for a ~/.vim/vimrc to exist.

--
hundred-and-one symptoms of being an internet addict:
171. You invent another person and chat with yourself in empty chat rooms.

skeept

unread,
Jun 4, 2013, 1:53:57 PM6/4/13
to vim...@googlegroups.com, Lech Lorens
On Monday, April 15, 2013 6:49:57 AM UTC-5, Bram Moolenaar wrote:
> Lech Lorens wrote:
>
>
>
> > On 13-Apr-2013 Bram Moolenaar wrote:
>
> > > Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
>
> > > be used. That should work for places where a new Vim is installed. For
>
> > > older Vim versions one would have to create a ~/.vimrc file that sources
>
> > > ~/.vim/vimrc.
>
> >
>
> > Do we want to change the priority? I meant not to confuse people if by
>
> > any chance they have both ~/.vimrc and ~/.vim/vimrc.
>
>
>
> In my opinion, when a user sees a ~/.vimrc he expects it to be used and
>
> would be very surprised when it is skipped. That is both for existing
>
> Vim users and any generic Unix user. Far fewer people would know about
>
> the possibility for a ~/.vim/vimrc to exist.
>
>

I don't remember if the patch discussed in this thread made it vim already...
If not is it to late to include for 7.4?

Regards,

Jorge

Bram Moolenaar

unread,
Jun 4, 2013, 3:42:35 PM6/4/13
to skeept, vim...@googlegroups.com, Lech Lorens
It's under the "slightly incompatible changes" list.
I'll probably include it, but I wonder if it hurts anyone.

--
hundred-and-one symptoms of being an internet addict:
91. It's Saturday afternoon in the middle of May and you
are on computer.

Gary Johnson

unread,
Jun 4, 2013, 4:49:23 PM6/4/13
to vim...@googlegroups.com
On 2013-06-04, Bram Moolenaar wrote:
> Skeept wrote:
>
> > On Monday, April 15, 2013 6:49:57 AM UTC-5, Bram Moolenaar wrote:
> > > Lech Lorens wrote:
> > >
> > >
> > > > On 13-Apr-2013 Bram Moolenaar wrote:
> > > > > Thanks. Thus only when ~/.vimrc does not exist then ~/.vim/vimrc will
> > > > > be used. That should work for places where a new Vim is installed. For
> > > > > older Vim versions one would have to create a ~/.vimrc file that sources
> > > > > ~/.vim/vimrc.
> > > >
> > > > Do we want to change the priority? I meant not to confuse people if by
> > > > any chance they have both ~/.vimrc and ~/.vim/vimrc.
> > >
> > > In my opinion, when a user sees a ~/.vimrc he expects it to be used and
> > > would be very surprised when it is skipped. That is both for existing
> > > Vim users and any generic Unix user. Far fewer people would know about
> > > the possibility for a ~/.vim/vimrc to exist.
> >
> > I don't remember if the patch discussed in this thread made it vim already...
> > If not is it to late to include for 7.4?
>
> It's under the "slightly incompatible changes" list.
> I'll probably include it, but I wonder if it hurts anyone.

If someone has a ~/.vimrc it won't make any difference.

If someone does not have a ~/.vimrc but does have a ~/.vim/vimrc,
the latter will be sourced now whereas it was not before.

That could happen if someone moved aside their ~/.vimrc for testing
or debugging, or is using ~/.exec instead of ~/.vimrc to share
settings between vim and another vi, or is using EXINIT instead of
~/.vimrc for some reason.

Those are the situations I can think of where this change might take
someone by unhappy surprise. All are cases where someone is
configuring Vim by unusual means _and_ happens to have a file named
vimrc laying around in their ~/.vim directory. It they don't like
the new behavior and don't want to change what they're doing, their
only solution is to rename their ~/.vim/vimrc file.

It doesn't seem like a big risk or problem to me, but I can't say
there's no risk.

Regards,
Gary

陈云杰

unread,
Jun 4, 2013, 7:42:34 PM6/4/13
to vim...@googlegroups.com

i like this patch

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages