简体   繁体   English

Vim的配置文件'_vimrc'中的设置是否遵循文档流程的顺序(从上到下)?

[英]Does settings in Vim's configuration file '_vimrc ' follow an order according to the document's flow (top to bottom)?

Its a bit weird, I wanted to deactivate automatic backups in gVIM when saving, so I placed set nobackup in the top of the file _vimrc and it didn't work. 有点奇怪,我想在保存时在gVIM中停用自动备份,因此我将set nobackup放置在文件_vimrc的顶部,但是它不起作用。 Then I placed that line below the following lines: 然后,将该行放置在以下行下面:

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

and it worked. 而且有效。

basically set nobackup doesn't works like this: 基本上set nobackup不能这样工作:

set nobackup

 set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin

and but works like this: 并且像这样工作:

 set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin

set nobackup

Is this normal? 这是正常的吗? Do VIM settings interfere with other settings? VIM设置会干扰其他设置吗?

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim

means that vim runs the configuration in those files before loading the lines after. 意味着vim在加载之后的行之前在那些文件中运行配置。 As "just somebody" said , in vimrc_example.vim, the backup is activated, so, in your first example, your first set the nobackup and then it's unactivated by the .vim file. 正如“某人”所说 ,在vimrc_example.vim中,备份被激活,因此,在您的第一个示例中,您首先设置了nobackup,然后它被.vim文件取消激活。

vimrc_example.vim contains: vimrc_example.vim包含:

if has("vms")
  set nobackup      " do not keep a backup file, use versions instead
else
  set backup        " keep a backup file
endif

you could have easily checked this yourself, you know. 您可以轻松地自己检查一下。 ;) ;)

edit 编辑

oh, and I'd suggest getting rid of the includes and the behave mswin directive. 哦,我建议您摆脱包含和behave mswin指令。 it makes vim turns vim into a different text editor. 它使vim将vim变成另一个文本编辑器。 one of vim's great strengths is that it works the same everywhere: MS Windows, X Windows, unix terminal... mswin voids this feature. vim的强项之一是,它在任何地方都可以使用:MS Windows,X Windows,Unix终端... mswin使此功能无效。

if you get used to ^S for :w and ^Q for ^V , you'll weep when you try to use vim in a unix terminal (they mean something to the terminal, and vim won't see the keystrokes at all); 如果您习惯:w ^S^Q ^V ^Q ,当您尝试在unix终端中使用vim时会哭泣(这对终端意味着一定的意义,而vim根本看不到按键)。 ; backspace is also troublesome ( ^H on most systems, ^? on GNU/Linux, different terminals have different defaults), ditto for delete and alt . 退格也很麻烦(在大多数系统上为^H ,在GNU / Linux上为^? ,不同的终端具有不同的默认值), 删除alt的同上。 etc. 等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM