Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
561 views
in Technique[技术] by (71.8m points)

editor - Making Vim portable

I am learning to use Vim and I want to have a portable version on my USB to edit my code here everywhere. I knew there are a portable version of Vim, but while i was searching for that version I found here an interesting comment:

I wouldn’t reccomend using portable vim. It is unmaintained, and vim can be made portable by just adding a few options in your vimrc.

I got intrigued. I would be glad to have the desktop version of GVim in my USB, but those lines aren't mentioned. Someone knows which vimrc options he is talking about?

*PD: I'm not a native English speaker, so If there are some writing errors, don't hesitate to tell me please :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are portable versions of vim that seem to be maintained, but personally I've never found a particular need for them: the standard Vim is portable enough for my needs.

Create a directory on your USB stick (let's assume that it's E: when you're creating it):

E:vim

Add two folders:

E:vimvim73
E:vimvimfiles

Copy the contents of C:Program Filesvimvim73 (or wherever it's installed) into E:vimvim73 and take your vim configuration files (if you have any) and put them in E:vimvimfiles. Copy your vimrc to E:vim\_vimrc.

Now put the USB stick in another PC (let's assume it mounts it as F:). Open Windows Explorer, navigate to F:vimvim73 and double click on gvim.exe. It will open the Vim GUI and load your configuration.


To keep the local and portable vim configurations matching, I'd recommend sticking the vimfiles directory under version control (also allows you to easily try out new plugins and then 'revert' to get rid of them if you don't want them) and having a checkout on the USB stick and another one on the PC. If you move your _vimrc to vimfilesvimrc and replace your _vimrc with the following, it will keep vimrc version controlled with all the plugins and configuration:

" _vimrc - Links to the vimrc in the vimfiles directory
runtime vimrc

You can do the same with _gvimrc if you have one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...