1

On my work project VM, I have a relatively common Vim set-up, with various files a in ~/.vim folder and a medium size ~/.vimrc file. Plugins installed from VimPlug store files in various folders, such as ~/.fzf.

However, should a co-worker want to use Vim on my system, or I want to be-able to quickly transfer my set-up to another VM (or put it on Git for my own keeping), they are currently forced to use my set-up. Currently the configuration and relevant files are spread out across the system which is not ideal for me.

How can I set up my Vim to keep it completely "self-contained" within a given folder, aside from the executable itself?

  • This has been asked in the past, even before the vi.stackexchange Beta. See https://stackoverflow.com/questions/4600009/making-vim-portable – wbogacz Nov 4 '18 at 10:44
  • If you use the packages feature of vim for plugins (or pathogen) then all of your plugins files will be in the .vim tree. Vimrc can also be relocated to ~/.vim/vimrc. Consider dotfiles setups too; some use symlinks or gnu stow to put everything in one spot. (Also, if your VM has more than one user they can have their own vim configs) – D. Ben Knoble Nov 4 '18 at 19:53
1

If you and co-worker(s) want to continuously work on the same systems, I'd recommend to use different user accounts, so that each has a different home directory. Unix was designed that way from the start.

If this is just for a short session, and your colleague would be confused by your customizations and remappings, you can quickly start up a vanilla Vim instance with

$ vim -u NONE

This isn't completely identical to a clean Vim installation, because default plugins (like netrw and matchparen) won't be loaded, neither. For that, the following command (best put to an alias) can be used:

$ vim --cmd 'set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after | if exists("+packpath") | let &packpath = &rtp | endif' -N -u NORC -c 'set rtp& | if exists("+packpath") | set packpath& | endif'

If this sharing happens a lot (because you're avid pair programmers), it might be worthwhile to separate your configuration into "standard" plugins (shared) and your personal remappings and tweaks. If you diligently separate these in your ~/.vimrc and surround the latter with if ! exists('g:sharedconfig'), you can launch a "cleaner" variant via

$ vim --cmd 'let g:sharedconfig = 1'

Going even further, your whole team could put their configurations / home directories on a network share, so that these are accessible from anywhere. This would also help with quickly setting up new systems with your own configuration (which I think is a different question, and has already been covered in depth elsewhere).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.