<h1 id="xdg-vim-config">xdg vim config</h1>
<p>To make vim load an alternative config file either use an alias or the VIMINIT variable. i.e. place either <code>alias vim="vim -u ~/.config/vim/vimrc"</code> or <code>VIMINIT="source ~/.config/vim/vimrc"</code> in your <code>.bashrc</code> (ironically, that one is still in my home folder).</p>
<p>Once that is loaded, you should source the following file after "nocompatible"</p>
<pre><code>&quot; file: ~/.config/vim/xdg.vim
if empty($XDG_CACHE_HOME)
    let $XDG_CACHE_HOME=$HOME.&quot;/.cache&quot;
endif

if empty($XDG_CONFIG_HOME)
    let $XDG_CONFIG_HOME=$HOME.&quot;/.config&quot;
endif

if empty($XDG_DATA_HOME)
    let $XDG_DATA_HOME=$HOME.&quot;/.local/share&quot;
endif

set directory=$XDG_CACHE_HOME/vim/swap,~/,/tmp
set backupdir=$XDG_CACHE_HOME/vim/backup,~/,/tmp
set undodir=$XDG_CACHE_HOME/vim/undo,~/,/tmp
set viminfo+=n$XDG_CACHE_HOME/vim/viminfo
set runtimepath+=$XDG_CONFIG_HOME/vim,$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/bundle/Vundle.vim,$VIM,$VIMRUNTIME
let $MYVIMRC=$XDG_CONFIG_HOME.&quot;/vim/vimrc&quot;
</code></pre>
<p>With this file in place you should call it from your vimrc</p>
<pre><code>&quot; file: ~/.config/vim/vimrc
set nocompatible
filetype off
source $HOME/.config/vim/xdg.vim
call vundle#begin()
let vundle#bundle_dir = expand(&quot;$XDG_DATA_HOME/vim/bundle&quot;)

&quot; include your calls to Plugin here

call vundle#end()
filetype plugin indent on
syntax on

source ~/.config.
</code></pre>
<p>Note that it is important that all the paths are defined BEFORE Vundle (or whatever is your plugin manager) is called, since the path to it is defined in <code>xdg.vim</code>.</p>
<p>You can check my full vim config at <a href="https://gitlab.com/crvs/dotfiles/-/tree/master/.config/vim">gitlab</a>.</p>
<h2 id="references">References</h2>
<p>The vim script I modified my config from - <a href="https://gist.github.com/dkasak/6ae1c6bf0d771155f23b">https://gist.github.com/dkasak/6ae1c6bf0d771155f23b</a></p>
