I've been working on expanding my vim-foo lately and I've run across a couple of plugins (autotag.vim for example) that require them to be "sourced" in my .vimrc file. What exactly does this mean and how do I do it?
The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.
vimrc . If you use a plugin manager like Vundle and keep the list of plugins in ~/. vimrc , then you'll need to source it after changing the list of installed plugins. There's no need to quit and restart!
Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.
Sourcing a file is 'executing' it. Essentially, each line of the file is considered a command. Sourcing it is the same as typing each command in order. You source with the command :source
(usually shortened to :so
).
So if you source myStuff.vim
:so myStuff.vim
and if myStuff.vim
contained these lines
set xx iI just intersted this<C-]> set yy bbbb4dw
It's the same as if you typed those commands into Vim
:set xx iI just intersted this<C-]> :set yy bbbb4dw
The only file sourced by default is the .vimrc
(_vimrc
on windows) so that's a place you can keep all the commands you use to set up Vim every time.
Where it gets interesting is the fact that since a sourced file is just a series of commands, and sourcing is a command, you can source files from your source files. So plugins you use every time could be sourced when you start up Vim by adding a line to your .vimrc
like this
so myPlugin.vim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With