Monday, June 16, 2014

Re: Keep consistent vim environments across different platforms

I have a MacBook, a Windows 7 box and an old Windows XP with softwares that I must keep, for support reasons. I had a Linux box too, but I don't longer have it. In all machines I use the same Vim/gVim configuration, plugins, syntax, indentation, etc, etc, etc. This is a long answer so...

First, I have a HOME environment variable in all machines. For Mac and Linux this is natural but on Windows you must do it your self. In my two Windows boxes I install Cygwin providing me with a much better shell than the original cmd. So my HOME environment in those Windows points to my user directory in Cygwin installation. So I put put my '.vim' folder in the HOME directory as usually its done on Mac or Linux. This means that even Cygwin Vim will work with the same configuration as Windows Vim.

On Windows, if Vim doesn't find a '_vimrc' file it will look for a '.vimrc' file. That was easy but the trick part is that it will not set the 'runtimepath' option with the '.vim' folder. It will stick with 'vimfiles' folder. So I work around that by moving '.vimrc' and '.gvimrc' inside '.vim' directory renaming it just 'vimrc' and 'gvimrc'. In my HOME directory the '.vimrc' file have this content in all machines:

if has('win32')
  let &runtimepath=substitute(&runtimepath, 'vimfiles', '.vim', 'g')
endif
runtime vimrc

And the '.gvimrc' in the root of my HOME directory has only:

runtime gvimrc

To keep the '.vim' directory in sync with all my machines I use git. I don't use plugin managers because I usually made some changes in the plugins I get. Is really rare I get a plugin and don't change anything so I prefer manual installations. But you can still use the plugin manager you like most removing the directories and files from git versioning with the help of '.gitignore' file.

I used Dropbox once. Its a more complicated setup since you cannot just sync the '.vim' folder you have. You must copy the '.vim' folder inside the 'Dropbox' folder and that make things not working well. I had the idea using 'rsync' to keep the '.vim' folder in sync with 'Dropbox/.vim' folder but had problems with timestamps on both Windows machines. After loosing some changes I moved to git. Now I can safely test a new plugin, by opening a new branch with git. If that plugin doesn't work as I thought it would I simply checkout back the previous branch and everything works just fine.

Wish I help.

Regards.


2014-06-02 22:46 GMT-03:00 DwigtArmyOfChampions <dwightarmyofchampions@hotmail.com>:
I have Vim installed on my work PC on a remote Linux server, and I have gVim installed on Windows on my work PC, and I have gVim installed on my home PC, and I have macvim on my laptop. I want all of these different instances of Vim to use the same environment and plugins and vimrc's. I want to set up a standard Vim environment so I can easily download everything to all my computers, and I also want to easily copy changes back up so I can make changes easily. What is an easy way to do this?

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment