簡體   English   中英

Windows版vim的默認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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM