Making Vim portable

后端 未结 5 1309
无人共我
无人共我 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:16

    Despite all the portable forks and complicated HOWTOs, making plain vim portable is pretty easy, actually I can't imagine it could get easier as you only need single line in config. At least on Windows, but I expect it to work elsewhere as well, let me know if I am wrong.

    tl;dr

    let $HOME=$VIM
    

    $VIM variable is relative to the executable and points to parent directory (Z:\vim-portable in our case).

    the unnecessarily long version

    Let's mix in directory structure and pathogen.

    1. Unpack the zips in vim74 dir:

      • vim74w32.zip (cmd version)
      • gvim74.zip (GUI version)
      • vim74rt.zip (runtime files)
    2. Create your _vimrc config file and insert:

      " Make vim portable.
      let $HOME=$VIM
      
      " Load and run pathogen.
      runtime bundle/vim-pathogen/autoload/pathogen.vim
      execute pathogen#infect()
      
    3. git clone pathogen into vimfiles/bundle dir. You could also just autoload pathogen, but I like it this way.

    And the tree looks like this:

    Z:\vim-portable
    |   _vimrc
    |   
    +---vim74
    |   |   gvim.exe
    |   |   vim.exe
    |   +---autoload
    |   +---colors
    |   +---compiler
    |   +---doc
    |   +---ftplugin
    |   +---indent
    |   +---keymap
    |   +---lang           
    |   +---macros
    |   +---plugin
    |   +---print
    |   +---spell 
    |   +---syntax
    |   +---tools
    \---vimfiles
        \---bundle
            \---vim-pathogen
    

提交回复
热议问题