vim 配置文件加载顺序笔记
最新代码:git clone https://github.com/vim/vim.git1. VIM执行入口 src/main.c,source_startup_scripts()执行初始化。 /* * Try to read initialization commands from the following places: * - env
最新代码:git clone https://github.com/vim/vim.git
1. VIM执行入口 src/main.c,source_startup_scripts()执行初始化。
/*
* Try to read initialization commands from the following places:
* - environment variable VIMINIT
* - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise)
* - second user vimrc file ($VIM/.vimrc for Dos)
* - environment variable EXINIT
* - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise)
* - second user exrc file ($VIM/.exrc for Dos)
* The first that exists is used, the rest is ignored.
*/
if (process_env((char_u *)"VIMINIT", TRUE) != OK)
{
if (do_source((char_u *)USR_VIMRC_FILE, TRUE, DOSO_VIMRC) == FAIL
#ifdef USR_VIMRC_FILE2
&& do_source((char_u *)USR_VIMRC_FILE2, TRUE,
DOSO_VIMRC) == FAIL
#endif
#ifdef USR_VIMRC_FILE3
&& do_source((char_u *)USR_VIMRC_FILE3, TRUE,
DOSO_VIMRC) == FAIL
#endif
#ifdef USR_VIMRC_FILE4
&& do_source((char_u *)USR_VIMRC_FILE4, TRUE,
DOSO_VIMRC) == FAIL
#endif
&& process_env((char_u *)"EXINIT", FALSE) == FAIL
&& do_source((char_u *)USR_EXRC_FILE, FALSE, DOSO_NONE) == FAIL
#ifdef USR_EXRC_FILE2
&& do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE) == FAIL
#endif
&& !has_dash_c_arg)
{
/* When no .vimrc file was found: source defaults.vim. */
do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE);
}
}
2. Autoload
/*
* Return the autoload script name for a function or variable name.
* Returns NULL when out of memory.
*/
char_u *
autoload_name(char_u *name)
{
char_u *p;
char_u *scriptname;
/* Get the script file name: replace '#' with '/', append ".vim". */
scriptname = alloc((unsigned)(STRLEN(name) + 14));
if (scriptname == NULL)
return FALSE;
STRCPY(scriptname, "autoload/");
STRCAT(scriptname, name);
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
STRCAT(scriptname, ".vim");
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
*p = '/';
return scriptname;
}
3. 参考starting.txt文档,help initialization 或者 help startup。
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)