Making Vim portable

后端 未结 5 1307
无人共我
无人共我 2020-12-12 16:33

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 searchi

5条回答
  •  失恋的感觉
    2020-12-12 17:10

    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:\vim\vim73
    E:\vim\vimfiles
    

    Copy the contents of C:\Program Files\vim\vim73 (or wherever it's installed) into E:\vim\vim73 and take your vim configuration files (if you have any) and put them in E:\vim\vimfiles. 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:\vim\vim73 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 vimfiles\vimrc 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.

提交回复
热议问题