vim configuraion files on windows

11 views
Skip to first unread message

Dmitry Teslenko

unread,
Sep 3, 2008, 2:38:54 AM9/3/08
to vim...@googlegroups.com
Hello!
I use vim on both windows/linux platforms. My personal configuration file for
vim is ~./.vimrc on both platforms; Why should then ~/.vim/colors, plugins, etc.
are processed only on linux platform and not on windows?
What should be configured to make vim process them on windows also?
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Anton Sharonov

unread,
Sep 3, 2008, 2:46:43 AM9/3/08
to Dmitry Teslenko
> Hello!
> I use vim on both windows/linux platforms. My personal configuration file for
> vim is ~./.vimrc on both platforms; Why should then ~/.vim/colors, plugins, etc.
> are processed only on linux platform and not on windows?
> What should be configured to make vim process them on windows also?

define HOME environment variable on windows to point to your home dir.
Put your .vimrc to the %HOME% directory. Create %HOME%/.vim directory,
put your vimfiles there as usual.

Insert following into the _beginning_ of your .vimrc:

if has("gui_running") && has("win32")
" to help win32-gui to locate d:\anton\.vim\{color,compiler,...}
" additionally - environment variable must be set:
" set HOME=d:\anton
set runtimepath+=~/.vim
endif

PS: In my setup it is even shared between cygwin / w32-gui gvim. And I
use Subversion to have it one-to-one on all my linux computers.

--
Mit freundlichen GrьЯen
Anton Sharonov
mailto:anton.s...@gmail.com


Dmitry Teslenko

unread,
Sep 3, 2008, 3:06:16 AM9/3/08
to vim...@googlegroups.com
On Wed, Sep 3, 2008 at 10:46, Anton Sharonov <anton.s...@gmail.com> wrote:
>
>> Hello!
>> I use vim on both windows/linux platforms. My personal configuration file for
>> vim is ~./.vimrc on both platforms; Why should then ~/.vim/colors, plugins, etc.
>> are processed only on linux platform and not on windows?
>> What should be configured to make vim process them on windows also?
>
> define HOME environment variable on windows to point to your home dir.
> Put your .vimrc to the %HOME% directory. Create %HOME%/.vim directory,
> put your vimfiles there as usual.
>
> Insert following into the _beginning_ of your .vimrc:
>
> if has("gui_running") && has("win32")
> " to help win32-gui to locate d:\anton\.vim\{color,compiler,...}
> " additionally - environment variable must be set:
> " set HOME=d:\anton
> set runtimepath+=~/.vim
> endif

set runtimepath+=~/.vim
works for me even w/o defining HOME outside gvim; gvim somehow
has $HOME already defined.

> PS: In my setup it is even shared between cygwin / w32-gui gvim. And I
> use Subversion to have it one-to-one on all my linux computers.

yep, that's cool. especially if that repositore is on the "colud"

Tony Mechelynck

unread,
Sep 3, 2008, 3:06:31 AM9/3/08
to vim...@googlegroups.com
On 03/09/08 08:38, Dmitry Teslenko wrote:
> Hello!
> I use vim on both windows/linux platforms. My personal configuration file for
> vim is ~./.vimrc on both platforms; Why should then ~/.vim/colors, plugins, etc.
> are processed only on linux platform and not on windows?
> What should be configured to make vim process them on windows also?

On Windows, the user-specific directory is not $HOME/.vim but
$HOME/vimfiles. If you want to use the same user-written scripts on both
sides of a double-boot computer, put them at $HOME/vimfiles on the
Windows side, with appropriate has() and/or exists() checks inside to
handle each system's idiosyncrasies, and create softlinks from ~/.vim on
the Linux side to wherever the Windows $HOME/vimfiles will be mounted
when Linux is running -- when I used double-boot it meant

cd ~
ln -sv /mnt/dos/c/Documents\ and\ Settings/Tony/My\
Documents/Home/vimfiles .vim

You may decide to mount that vfat or ntfs filesystem elsewhere and/or to
have your %HOME% directory elsewhere (the above was not the Windows default)

$VIM/vimfiles (which is system-wide) is a name common to both, but of
course it will resolve differently, as /usr/local/share/vim on one side
and as "C:\Program Files\Vim" (which is not even on the same filesystem)
on the other side. Similarly, both $VIMRUNTIME directories will be
$VIM/vim72 but they won't be the same either.


Best regards,
Tony.
--
A celebrity is a person who is known for his well-knownness.

George V. Reilly

unread,
Sep 3, 2008, 3:30:24 AM9/3/08
to vim...@googlegroups.com


2008/9/3 Dmitry Teslenko <dtes...@gmail.com>


On Wed, Sep 3, 2008 at 10:46, Anton Sharonov <anton.s...@gmail.com> wrote:
>
>> Hello!
>> I use vim on both windows/linux platforms. My personal configuration file for
>> vim is ~./.vimrc on both platforms; Why should then ~/.vim/colors, plugins, etc.
>> are processed only on linux platform and not on windows?
>> What should be configured to make vim process them on windows also?


I took a somewhat different approach to sharing .vimrc and .vim/ between Windows, Mac, and Linux: http://www.georgevreilly.com/blog/2008/05/14/SharingDotfilesBetweenWindowsAndNix.aspx

--
/George V. Reilly geo...@reilly.org
http://www.georgevreilly.com/blog http://blogs.cozi.com/tech

Ben Schmidt

unread,
Sep 3, 2008, 6:13:19 AM9/3/08
to vim...@googlegroups.com
>> set runtimepath+=~/.vim

This is not a very good idea.

It will add ~/.vim to the end of runtimepath, but it should be at the
beginning of it, and ~/.vim/after should be at the end.

I suggest either using vimfiles instead of .vim on Windows, which is
what Vim defaults to using on that platform (make a link for Linux use),
or put this in your .vimrc instead:

let &rtp=substitute(&rtp,'[\\/]\zsvimfiles\ze\([\\/,]\|$\)','.vim','g')

which should change the appropriate 'vimfiles' into '.vim' in your runtime
path rather than adding '.vim' in the wrong place. I haven't tested it
though (it's tricky without being on Windows!).

Ben.


A. S. Budden

unread,
Sep 3, 2008, 6:16:53 AM9/3/08
to vim...@googlegroups.com
2008/9/3 Ben Schmidt <mail_ben...@yahoo.com.au>:

This might not be very helpful, but I have a copy of my vimfiles
directory in ~/.vim (on Linux), c:\cygwin\home\al\.vim (for cygwin)
and C:\vim\vimfiles (for Windows). They're all linked with subversion
(and vimrc is in the vimfiles directory and merely linked to by the
default location). Cygwin vim uses c:\cygwin\home\al\.vim whereas
Windows Vim uses c:\vim\vimfiles and it all works very nicely.

http://vim.wikia.com/wiki/Version_Control_for_Vimfiles

Al

Anton Sharonov

unread,
Sep 3, 2008, 7:02:27 AM9/3/08
to Ben Schmidt
>>> set runtimepath+=~/.vim

Ben ! Thanks a _lot_ for your substitute command, I have already put
it into my .vimrc as replacement of my version. That's again one
example why I love this list. One thing what I not
understand is : why I have no problems using my former setting ?
Is it because I never used any */after/* functionality ?

Anyway, I have briefly tested it -
at least w32 gvim is still startable and finds my colorscheme and seems
to works. If there will be some problems with it, I will report them here.

At the beginning I have also used symlinks _vimrc -> .vimrc, vimfiles
-> .vim, but flat structure, which I have now is for me huge advantage
in usability, especially since I start to directly share ~/.vimrc
~/.vim with cygwin vim without necessity of "svn update" for some
another directories. Single
caveat (exactly how it is mentioned on George V. Reilly blog page), is
that one must always checkout vim files using cygwin svn to get unix
EOL's in all files with svn:eol-style=native (or process them all with
- untested - find ~/.vim -iname '*.vim' | xargs dos2unix).

Tony Mechelynck

unread,
Sep 3, 2008, 7:25:11 AM9/3/08
to vim...@googlegroups.com

Symlinks _vimrc <-> .vimrc are not necessary if the directory can be
found, becaure if .vimrc cannot be found, Unix Vim will look for _vimrc,
and vice-versa for Windows. A symlink .vim -> vimfiles can be useful in
some cases (and remember that Linux can read fat and ntfs filesystems,
but Windows cannot read ext2, ext3, reiser, etc.).


Best regards,
Tony.
--
"Life is like a buffet; it's not good but there's plenty of it."

Ben Schmidt

unread,
Sep 3, 2008, 5:06:09 PM9/3/08
to vim...@googlegroups.com
>>>> set runtimepath+=~/.vim
>
>> This is not a very good idea.
>
>> It will add ~/.vim to the end of runtimepath, but it should be at the
>> beginning of it, and ~/.vim/after should be at the end.
>
>> I suggest either using vimfiles instead of .vim on Windows, which is
>> what Vim defaults to using on that platform (make a link for Linux use),
>> or put this in your .vimrc instead:
>
>> let
>> &rtp=substitute(&rtp,'[\\/]\zsvimfiles\ze\([\\/,]\|$\)','.vim','g')
>
>> which should change the appropriate 'vimfiles' into '.vim' in your runtime
>> path rather than adding '.vim' in the wrong place. I haven't tested it
>> though (it's tricky without being on Windows!).
>
> Ben ! Thanks a _lot_ for your substitute command, I have already put
> it into my .vimrc as replacement of my version.

You're welcome.

> That's again one
> example why I love this list. One thing what I not
> understand is : why I have no problems using my former setting ?
> Is it because I never used any */after/* functionality ?

It would work if you never used any */after/* functionality, and if all
the regular functionality you used didn't rely on running before the
distributed runtime files. A good number of examples in the help and
that people give on this list do rely on that, however, and a messed-up
runtimepath would be one of the last things we'd think to check when it
didn't work!

Smiles,

Ben.


George V. Reilly

unread,
Sep 3, 2008, 6:14:32 PM9/3/08
to vim...@googlegroups.com


2008/9/3 Anton Sharonov <anton.s...@gmail.com>

At the beginning I have also used symlinks _vimrc -> .vimrc, vimfiles
-> .vim, but flat structure, which I have now is for me huge advantage
in usability, especially since I start to directly share ~/.vimrc
~/.vim with cygwin vim without necessity of "svn update" for some
another directories. Single
caveat (exactly how it is mentioned on George V. Reilly blog page), is
that one must always checkout vim files using cygwin svn to get unix
EOL's in all files with svn:eol-style=native (or process them all with
- untested - find ~/.vim -iname '*.vim' | xargs dos2unix).

Another way to deal with this is to mark *.vim as svn:eol-style=native. On Windows, they'll be checked out with CRLF line endings. On other platforms, they'll get LF line endings.

George V. Reilly

unread,
Sep 3, 2008, 6:18:30 PM9/3/08
to vim...@googlegroups.com
2008/9/3 Tony Mechelynck <antoine.m...@gmail.com>


Symlinks _vimrc <-> .vimrc are not necessary if the directory can be
found, becaure if .vimrc cannot be found, Unix Vim will look for _vimrc,
and vice-versa for Windows. A symlink .vim -> vimfiles can be useful in
some cases (and remember that Linux can read fat and ntfs filesystems,
but Windows cannot read ext2, ext3, reiser, etc.).

Windows has no built-in support for ext2 or ext3. However, I successfully used ext2ifs <http://www.fs-driver.org/> under Windows XP on a multiboot system for many months.

If you install NTFS-3G, Linux and Mac can write -- as well as read -- NTFS file systems. Otherwise, you're limited to only reading NTFS.

Anton Sharonov

unread,
Sep 4, 2008, 1:04:06 AM9/4/08
to vim...@googlegroups.com
Yes, I use svn:eol-style=native property already. As you say, it
is useful to set svn:eol-style to native for all *.vim files.

And one more trick, if one uses both cygwin vim and w32 gvim: to
share physically the same configuration files between cygwin vim
and w32 gvim one can checkout those files using cygwin
(/usr/bin/svn) svn client, which will create all files with UNIX
EOL's by default. Than both cygwin vim and w32 gvim are able to
work with them properly. If *.vim files are checked out using
windows svn client (for example TortoiseSVN), files are created
with WINDOWS EOL's and are usable only from w32 gvim and not from
cygwin vim. Thats working copy, where *.vim files have WINDOWS
EOL's, can be fixed either by removing the working copy and
checking it out once more using cygwin svn client, or by using
following command from cygwin shell
- untested - find ~/.vim -iname '*.vim' | xargs dos2unix.

2008/9/4, George V. Reilly <geo...@reilly.org>:

Benjamin Fritz

unread,
Sep 4, 2008, 9:53:41 AM9/4/08
to vim...@googlegroups.com
On Thu, Sep 4, 2008 at 12:04 AM, Anton Sharonov
<anton.s...@gmail.com> wrote:
>
> Yes, I use svn:eol-style=native property already. As you say, it
> is useful to set svn:eol-style to native for all *.vim files.
>
> And one more trick, if one uses both cygwin vim and w32 gvim: to
> share physically the same configuration files between cygwin vim
> and w32 gvim one can checkout those files using cygwin
> (/usr/bin/svn) svn client, which will create all files with UNIX
> EOL's by default. Than both cygwin vim and w32 gvim are able to
> work with them properly. If *.vim files are checked out using
> windows svn client (for example TortoiseSVN), files are created
> with WINDOWS EOL's and are usable only from w32 gvim and not from
> cygwin vim. Thats working copy, where *.vim files have WINDOWS
> EOL's, can be fixed either by removing the working copy and
> checking it out once more using cygwin svn client, or by using
> following command from cygwin shell
> - untested - find ~/.vim -iname '*.vim' | xargs dos2unix.
>

I'm confused as to why all this is needed.

Vim (and most other modern Windows programs) work perfectly fine with
files encoded with Unix line endings.

Anton Sharonov

unread,
Sep 4, 2008, 10:14:19 AM9/4/08
to Benjamin Fritz
Guten Tag Benjamin Fritz,

am Donnerstag, 04. September 2008 um 15:53 schrieben Sie:
Exactly. You can use unix encoding for both.

But not windows file encoding for both (windows file encoding you get
if you checkout your working copy ~/.vim/** using TortoiseSVN - it is
than unusable for cygwin vim.

--
Mit freundlichen Grüßen
Anton Sharonov
mailto:anton.s...@gmail.com


Reply all
Reply to author
Forward
0 new messages