查看vim 的启动过程。 确定自己vim 插件的存放位置

有vim ,欲加入自己的plugin.

1. set runtimepath 可以查看搜索的路径

2. vim -V 可以查看到具体加载路径

vim --help, 看到

-V[N][fname]         Be verbose [level N] [log messages to fname]

vim -V,默认verbose 是10。每一个自动运行命令都会被显示

vim -V 2>verbose

cat verbose.

 

XSMP opening connection
chdir(/opt/share/vim)
fchdir() to previous dir
could not source "$VIM/vimrc"
chdir(/home/hjj)
fchdir() to previous dir
sourcing "$HOME/.vimrc"
chdir(/opt/share/vim/vim74/syntax)
fchdir() to previous dir
line 56: sourcing "/opt/share/vim/vim74/syntax/syntax.vim"
Searching for "syntax/synload.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/syntax/synload.vim"
Searching for "/opt/share/vim/vimfiles/syntax/synload.vim"
Searching for "/opt/share/vim/vim74/syntax/synload.vim"
chdir(/opt/share/vim/vim74/syntax)
fchdir() to previous dir
line 19: sourcing "/opt/share/vim/vim74/syntax/synload.vim"
Searching for "syntax/syncolor.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/syntax/syncolor.vim"
Searching for "/opt/share/vim/vimfiles/syntax/syncolor.vim"
Searching for "/opt/share/vim/vim74/syntax/syncolor.vim"
chdir(/opt/share/vim/vim74/syntax)
fchdir() to previous dir
line 21: sourcing "/opt/share/vim/vim74/syntax/syncolor.vim"
finished sourcing /opt/share/vim/vim74/syntax/syncolor.vim
continuing in /opt/share/vim/vim74/syntax/synload.vim
Searching for "/opt/share/vim/vimfiles/after/syntax/syncolor.vim"
Searching for "/home/hjj/.vim/after/syntax/syncolor.vim"
finished sourcing /opt/share/vim/vim74/syntax/synload.vim
continuing in /opt/share/vim/vim74/syntax/syntax.vim
Searching for "filetype.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/filetype.vim"
Searching for "/opt/share/vim/vimfiles/filetype.vim"
Searching for "/opt/share/vim/vim74/filetype.vim"
chdir(/opt/share/vim/vim74)
fchdir() to previous dir
line 25: sourcing "/opt/share/vim/vim74/filetype.vim"
Searching for "ftdetect/*.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/ftdetect/*.vim"
Searching for "/opt/share/vim/vimfiles/ftdetect/*.vim"
Searching for "/opt/share/vim/vim74/ftdetect/*.vim"
Searching for "/opt/share/vim/vimfiles/after/ftdetect/*.vim"
Searching for "/home/hjj/.vim/after/ftdetect/*.vim"
not found in 'runtimepath': "ftdetect/*.vim"
finished sourcing /opt/share/vim/vim74/filetype.vim
continuing in /opt/share/vim/vim74/syntax/syntax.vim
Searching for "/opt/share/vim/vimfiles/after/filetype.vim"
Searching for "/home/hjj/.vim/after/filetype.vim"
finished sourcing /opt/share/vim/vim74/syntax/syntax.vim
continuing in /home/hjj/.vimrc
Searching for "filetype.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/filetype.vim"
Searching for "/opt/share/vim/vimfiles/filetype.vim"
Searching for "/opt/share/vim/vim74/filetype.vim"
chdir(/opt/share/vim/vim74)
fchdir() to previous dir
line 67: sourcing "/opt/share/vim/vim74/filetype.vim"
finished sourcing /opt/share/vim/vim74/filetype.vim
continuing in /home/hjj/.vimrc
Searching for "/opt/share/vim/vimfiles/after/filetype.vim"
Searching for "/home/hjj/.vim/after/filetype.vim"
Searching for "ftplugin.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/ftplugin.vim"
Searching for "/opt/share/vim/vimfiles/ftplugin.vim"
Searching for "/opt/share/vim/vim74/ftplugin.vim"
chdir(/opt/share/vim/vim74)
fchdir() to previous dir
line 67: sourcing "/opt/share/vim/vim74/ftplugin.vim"
finished sourcing /opt/share/vim/vim74/ftplugin.vim
continuing in /home/hjj/.vimrc
Searching for "/opt/share/vim/vimfiles/after/ftplugin.vim"
Searching for "/home/hjj/.vim/after/ftplugin.vim"
Searching for "indent.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/indent.vim"
Searching for "/opt/share/vim/vimfiles/indent.vim"
Searching for "/opt/share/vim/vim74/indent.vim"
chdir(/opt/share/vim/vim74)
fchdir() to previous dir
line 67: sourcing "/opt/share/vim/vim74/indent.vim"
finished sourcing /opt/share/vim/vim74/indent.vim
continuing in /home/hjj/.vimrc
Searching for "/opt/share/vim/vimfiles/after/indent.vim"
Searching for "/home/hjj/.vim/after/indent.vim"
Searching for "syntax/syncolor.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/syntax/syncolor.vim"
Searching for "/opt/share/vim/vimfiles/syntax/syncolor.vim"
Searching for "/opt/share/vim/vim74/syntax/syncolor.vim"
chdir(/opt/share/vim/vim74/syntax)
fchdir() to previous dir
line 111: sourcing "/opt/share/vim/vim74/syntax/syncolor.vim"
finished sourcing /opt/share/vim/vim74/syntax/syncolor.vim
continuing in /home/hjj/.vimrc
Searching for "/opt/share/vim/vimfiles/after/syntax/syncolor.vim"
Searching for "/home/hjj/.vim/after/syntax/syncolor.vim"
finished sourcing $HOME/.vimrc
Searching for "plugin/**/*.vim" in "/home/hjj/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,/home/hjj/.vim/after"
Searching for "/home/hjj/.vim/plugin/**/*.vim"
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/a.vim"
finished sourcing /home/hjj/.vim/plugin/a.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/debug.vim"
finished sourcing /home/hjj/.vim/plugin/debug.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/gdb_mappings.vim"
finished sourcing /home/hjj/.vim/plugin/gdb_mappings.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/grepit.vim"
finished sourcing /home/hjj/.vim/plugin/grepit.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/highlight.vim"
finished sourcing /home/hjj/.vim/plugin/highlight.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/man.vim"
finished sourcing /home/hjj/.vim/plugin/man.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/matchit.vim"
finished sourcing /home/hjj/.vim/plugin/matchit.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/mru.vim"
finished sourcing /home/hjj/.vim/plugin/mru.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/numsign.vim"
finished sourcing /home/hjj/.vim/plugin/numsign.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/project.vim"
finished sourcing /home/hjj/.vim/plugin/project.vim
chdir(/home/hjj/.vim/plugin)
fchdir() to previous dir
sourcing "/home/hjj/.vim/plugin/taglist.vim"
finished sourcing /home/hjj/.vim/plugin/taglist.vim
Searching for "/opt/share/vim/vimfiles/plugin/**/*.vim"
Searching for "/opt/share/vim/vim74/plugin/**/*.vim"
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/getscriptPlugin.vim"
finished sourcing /opt/share/vim/vim74/plugin/getscriptPlugin.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/gzip.vim"
finished sourcing /opt/share/vim/vim74/plugin/gzip.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/matchparen.vim"
finished sourcing /opt/share/vim/vim74/plugin/matchparen.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/netrwPlugin.vim"
finished sourcing /opt/share/vim/vim74/plugin/netrwPlugin.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/rrhelper.vim"
finished sourcing /opt/share/vim/vim74/plugin/rrhelper.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/spellfile.vim"
finished sourcing /opt/share/vim/vim74/plugin/spellfile.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/tarPlugin.vim"
finished sourcing /opt/share/vim/vim74/plugin/tarPlugin.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/tohtml.vim"
finished sourcing /opt/share/vim/vim74/plugin/tohtml.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/vimballPlugin.vim"
finished sourcing /opt/share/vim/vim74/plugin/vimballPlugin.vim
chdir(/opt/share/vim/vim74/plugin)
fchdir() to previous dir
sourcing "/opt/share/vim/vim74/plugin/zipPlugin.vim"
finished sourcing /opt/share/vim/vim74/plugin/zipPlugin.vim
Searching for "/opt/share/vim/vimfiles/after/plugin/**/*.vim"
Searching for "/home/hjj/.vim/after/plugin/**/*.vim"
Opening the X display took 0 msec
Reading viminfo file "/home/hjj/.viminfo" info oldfilesOpening the X display took 1 msec
Press ENTER or type command to continueXSMP handling save-yourself request


启动完之后,看看加载后的结果:

    .vimrc 脚本启动分析
  当我们启动vim后, 打人scriptnames, 可以看到加载的脚本, 我给它加了注释,能够看到它在什么时间加载的,因何而加.
  具体的启动过程用vim -V 2>vimrc.txt 可以看到vim 的启动过程,这里是简化注释.

scriptnames
    
  1: ~/.vimrc  自动加载, 在line 56 有syntax on, 所以加载syntax.vim
                                脚本是嵌套加载的,一层可以套一层,相当于include
  2: /opt/share/vim/vim74/syntax/syntax.vim,         <<<< line 19 runtime syntax/synload.vim
    要依照runtime 搜索路径查找,即 .vim,vimfiles,vim74,vimfiles/after,.vim/after
  3: /opt/share/vim/vim74/syntax/synload.vim         <<<< line 21, runtime! syntax/syncolor.vim
  4: /opt/share/vim/vim74/syntax/syncolor.vim         :: 加载完syncolor.vim ,加载完synload.vim 再继续加载syntax.vim
                                      syntax.vim         <<<< line 25 filetype on
  5: /opt/share/vim/vim74/filetype.vim                 :: 加载完filetype.vim 加载完syntax.vim,再继续加载.vimrc
                                    .vimrc          <<<< line 67 filetype plugin indent on
                                                    :: filetype.vim 已经加载过了,plugin,indent 打开,所以加载ftplugin.vim,indent.vim
  6: /opt/share/vim/vim74/ftplugin.vim
  7: /opt/share/vim/vim74/indent.vim
                                    .vimrc            :: 加载结束,同时把plugin目录下所有插件加载到内存,用来扩展功能!!
                                                    :: 后面都是简单的source,finish 直线运行,没有包含就没有嵌套.
  8: ~/.vim/plugin/a.vim
  9: ~/.vim/plugin/debug.vim
 10: ~/.vim/plugin/gdb_mappings.vim
 11: ~/.vim/plugin/grepit.vim
 12: ~/.vim/plugin/highlight.vim
 13: ~/.vim/plugin/man.vim
 14: ~/.vim/plugin/matchit.vim
 15: ~/.vim/plugin/mru.vim
 16: ~/.vim/plugin/numsign.vim
 17: ~/.vim/plugin/project.vim
 18: ~/.vim/plugin/taglist.vim
 19: /opt/share/vim/vim74/plugin/getscriptPlugin.vim
 20: /opt/share/vim/vim74/plugin/gzip.vim
 21: /opt/share/vim/vim74/plugin/matchparen.vim
 22: /opt/share/vim/vim74/plugin/netrwPlugin.vim
 23: /opt/share/vim/vim74/plugin/rrhelper.vim
 24: /opt/share/vim/vim74/plugin/spellfile.vim
 25: /opt/share/vim/vim74/plugin/tarPlugin.vim
 26: /opt/share/vim/vim74/plugin/tohtml.vim
 27: /opt/share/vim/vim74/plugin/vimballPlugin.vim
 28: /opt/share/vim/vim74/plugin/zipPlugin.vim

 

 

于是确定,自己的vimfiles 加载的位置放置于 .vim/plugin 目录下, 实现功能扩展。且不影响系统功能。

操作:

1. 在家目录下,创建.vim 目录

2. 在.vim 目录下,创建plugin 目录。

3. 将自己的插件copy 与此。

4. 用scriptnames, 查看结果。

 

乙: 用runtimepath 来查看。

  runtimepath=~/.vim,/opt/share/vim/vimfiles,/opt/share/vim/vim74,/opt/share/vim/vimfiles/after,~/.vim/after

 

简单明了, 就是vim 的运行查找路径

你可能感兴趣的:(vim&emacs)