如何在多个客户端之间共享一个 vimrc 文件? [英] How to share one vimrc file among multiple clients?

查看:30
本文介绍了如何在多个客户端之间共享一个 vimrc 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时不是一个非常有秩序的人,我经常发现自己丢失了旧的完全调整过的 vimrc 文件,不得不重新开始.或者在不同的客户端上有不同版本的 vimrc 文件.由于这种混乱对我来说已经失控,我想知道是否有一种管理我的 vimrc 文件的好方法.

I am not a very orderly person at times and I often find myself in the situation of losing my old fully tweaked vimrc file and having to start over all again. Or having different versions of vimrc files on different clients. Since this mess is getting out of hand for me, I would like to know if there is a good way of managing my vimrc file.

我的第一个举措是将我的 _vimrc 放在 subversion(谷歌代码)上,我打算维护它.欢迎其他想法.

My first initiative is put my _vimrc on subversion (Google Code) and I intend to maintain it. Other ideas are welcome.

我解决了以下解决方案:

I settled with the following solution:

  • .vimrc.gvimrc 上传到名为 Vim 的目录中的在线代码库.使用文件名 _vimrc_gvimrc 使它们不被隐藏,并与 Windows 兼容.

  • Upload the .vimrc and .gvimrc to an online code repository in a directory called Vim. Use filename _vimrc and _gvimrc so that they aren't hidden, and for compatibility with Windows.

签出目标系统上的存储库

Checkout the repository on the target system

在 Mac OSX/Linux 上创建符号链接:

On Mac OSX/Linux create symbolic links:

~ $ ln -s my_repository/Vim/_vimrc $HOME/.vimrc

~ $ ln -s my_repository/Vim/_gvimrc $HOME/.gvimrc

在 Windows 上,我在 Program Files 目录中检出 Vim 文件夹.SVN 抱怨那里已经存在的文件,但您可以将它们添加到忽略列表中.

On Windows I checkout the Vim folder over the one in the Program Files directory. SVN complains about already existing files there, but you can add those to the ignore list.

推荐答案

我使用 Dropbox.我在 Dropbox 中创建了一个文件夹 vim,其中包含我的 .vimrc(实际上是:vimrc.vim)和 colorsplugin 等目录.

I use Dropbox. I've created a folder vim in my dropbox, which contains my .vimrc (actually: vimrc.vim) and colors, plugin, etc. directories.

Dropbox 将所有这些文件推送到我所有的电脑(家庭、工作、笔记本电脑、Bootcamp),所以每次我想更改我的 vimrc 时,我都可以这样做,我不必担心将它复制到正确的目录或从 SVN 或任何东西中检出文件.一切都是自动发生的!

Dropbox pushes all these files to all my computers (home, work, laptop, Bootcamp), so every time I want to change my vimrc, I can do so and I don't have to worry about copying it to the correct directory or checking out the file from SVN or anything. Everything happens automagically!

我实际的 .vimrc 只包含加载我在 Dropbox 中的东西所必需的内容.在 OSX 和 Linux 上,它看起来像这样:

My actual .vimrc contains only what's necessary to load the stuff I have in my Dropbox. On OSX and Linux, it looks like this:

set runtimepath^=~/Dropbox/vim
source ~/Dropbox/vim/vimrc.vim

在 Windows 上,像这样:

On Windows, like this:

set runtimepath^=$HOME/My\ Documents/My\ Dropbox/vim
source $HOME\My Documents\My Dropbox\vim\vimrc.vim

就是这样!

(实际上,我将上面的 vimrc 也放在了我的 Dropbox 中,因此每当我设置新计算机或重新安装旧计算机时,我都不必记住它们.)

(Actually, I put the vimrc's above in my Dropbox as well, so I don't have to remember them whenever I set up a new computer or re-install an old one.)

免费版 Dropbox 会给你 30 天的修订历史,付费版会给你完整的修订历史.请注意,如果您使用的是 Linux,那么使用 GNOME 是最简单的,Dropbox 有一个很好的客户端.

The free version of Dropbox will give you a 30 day revision history, the paid one will give you full revision history. Note that if you're on Linux, it's easiest if you use GNOME, for which Dropbox has a nice client.

如果您想在不同的机器上使用轻微的配置更改,这是一个方便的解决方案:

If you have slight configuration changes you would like to use on different machines this is a handy solution:

在您的每个 .vimrc 文件中创建一个小函数来返回您所在的系统类型:

create a small function in each of your .vimrc files to return the type of system you are on:

fun! MySys()
    return 'linux'
endfun 

然后在你的全局 vimrc.vim 文件中:

then in your global vimrc.vim file:

if MySys() == "linux"
    set backupdir=./.backup,/tmp
    set directory=./.backup,/tmp 
elseif MySys() == "windows"
    set backupdir=$HOME/AppData/Local/backup,$HOME/AppData/Local/tmp
    set directory=$HOME/AppData/Local/backup,$HOME/AppData/Local/tmp
endif

Dropbox 替代品

有很多云存储和同步服务,Dropbox 只是一个例子.开源服务,例如 http://sparkleshare.org/http://one.ubuntu.com 存在,但我们鼓励您在互联网上搜索最适合您需求的解决方案.

Dropbox Alternatives

There are many cloud storage and syncing services, Dropbox is just one example. OpenSource services such as http://sparkleshare.org/ and http://one.ubuntu.com exist, but you are encouraged to search the internet for a solution that will fit your needs best.

这篇关于如何在多个客户端之间共享一个 vimrc 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆