How do I “create” something in my .vimrc file?

I have been working on an extension of my vim-foo recently, and I came across several plugins ( autotag.vim for example) that require them to be “received” in my .vimrc file. What exactly does this mean and how to do it?

+80
vim plugins vi
Apr 29 '09 at 17:39
source share
4 answers

A file search is its execution. In fact, each line of the file is considered a command. Sourcing is the same as entering each command in order. A source with the command :source (usually shortened to :so ).

So if you use myStuff.vim

 :so myStuff.vim 

and if myStuff.vim contains these lines

 set xx iI just intersted this<C-]> set yy bbbb4dw 

It is the same as if you entered these commands in Vim

 :set xx iI just intersted this<C-]> :set yy bbbb4dw 

The only file whose source is by default is .vimrc ( _vimrc on windows), so there’s a place where you can save all the commands you use to configure Vim every time.

It becomes interesting that since the source file is just a series of commands, and the sourcing command is a command, you can use the source files from your source files. So the plugins that you use every time can be obtained when Vim starts by adding a line to your .vimrc , like this

  so myPlugin.vim 
+94
Apr 30 '09 at 3:25
source share

Files in your .vim / plugin directory are automatically uploaded (uploaded).

+36
Apr 29 '09 at 17:42
source share

There is always a command : the source file . Usually I write .vimrc , which contains user commands and that is not for the console application, and then .gvimrc , which contains additional goodies that are suitable for the window version. My .gvimrc starts with source $HOME/.vimrc to select everything from the console version before adding new things.

+12
Apr 29 '09 at 17:47
source share

There are usually two vimrc files, one is _vimrc and the other is _gvimrc (in the first, things for vim, and in the second for gvim, graphic objects) - although most of the people I know just put everything in _vimrc.

It’s good practice to save all your additional files (plugins, colors, fragments ...) in a separate (your own) vimfiles directory (which you can take with you).

If you do

 :help vimfiles 

vim will tell you that your vimfiles directory should be located. It depends a little on the platform (win, unix). The windows usually contain your user folder (documents and settings, then the user ...). There are several subdirectories in the vimfiles directory. Among them is the "plugin" subdirectory. Plugins placed in this directory will be loaded automatically (also plugins are placed in subdirectories of the "plugin"). If you don’t want to download it automatically, just put it in your "vimfiles" or in some other directory and

 :so plugin_name.vim (with the appropriate path) (you can use the $vim, $vimfiles, and $home as shortcuts when defining path to plugin) 
+5
Apr 29 '09 at 18:06
source share



All Articles