Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I "source" something in my .vimrc file?

Tags:

vim

vi

plugins

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?

like image 357
Paul Wicks Avatar asked Apr 29 '09 17:04

Paul Wicks


People also ask

How do I access .vimrc files?

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.

Do you need to source vimrc?

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!

How do I edit my vimrc file?

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.


1 Answers

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 
like image 177
Whaledawg Avatar answered Oct 14 '22 23:10

Whaledawg