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

后端 未结 4 1956
孤独总比滥情好
孤独总比滥情好 2021-01-30 00:39

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

4条回答
  •  -上瘾入骨i
    2021-01-30 01:15

    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
    set yy bbbb4dw
    

    It's the same as if you typed those commands into Vim

    :set xx iI just intersted this
    :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
    

提交回复
热议问题