![](/img/trans.png)
[英]Vim/gVim 8.1 on Windows 10 won't source $HOME\_vimrc
[英]Explanation of default vimrc file for windows version of vim
我刚刚下载了vim7.4 for windows,我想知道它附带的默认vimrc文件是做什么的。 只需对每个项目进行简要说明即可。 这里是。
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
set nocompatible
默认情况下,Vim的行为与其祖先vi相似。 这对于快速编辑来说并不是一个真正的问题,但如果您打算使用它超过10分钟,它会非常糟糕。 set nocompatible
使得Vim比Vi更像Vim。
请参阅:help nocompatible
。
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
来源这两个文件。 vimrc_example.vim
包含示例设置。 看看它可能是一个好主意:它可能包含有用的东西。
behave mswin
mswin.vim
包含一系列设置和映射,旨在使Vim或多或少像典型的Windows编辑器一样工作,如<Cv>
粘贴。 这个命令“激活”了这种愚蠢的行为。
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
这是一个定义Vim在用于区分两个或多个缓冲区时的行为的函数。 对我来说,它看起来更像是一个黑客而不是其他任何东西。 它似乎是检查你的Windows环境是否能够自己做差异,如果没有,使用内置差异。
如果你打算认真使用/学习Vim,上面的任何一个都不应该进入你的$HOME\\_vimrc
。 如果Vim找到$HOME\\_vimrc
则自动为您设置nocompatible
即使是第一行也不行。
我并不熟悉Windows,因此差异部分可能很有用,但您可以安全地放弃其余部分。
当你看到set something
,做:help 'something
(用单引号)。
您可能已经想到了这一点,但是如果删除vimrc_example.vim源,您可能想要添加的一件事就是syntax on
。 没有这一点,文本将在gvim的无色无论colorscheme
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.