繁体   English   中英

为什么我的.vimrc中的某些设置不起作用?

[英]Why are some settings in my .vimrc not working?

这是我的.vimrc(我在Windows XP上使用gVimPortable):

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

syntax enable
set background=light
colorscheme solarized

set formatoptions+=t
set tw=10

nmap <leader>s dwwP

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

出于某种原因, colorscheme可以工作,但是诸如set formatoptions+=tset tw=10则不能

文本完全不被换行(长度超过10个字符)。

可能是什么问题呢?

诸如'formatoptions''formatoptions'设置通常由文件类型插件修改(您可以通过vimrc_example.vim启用它们)。

您可以通过以下方式找到该选项的最后修改位置

:verbose setlocal formatoptions?

如果那样给您ftplugin/foo.vim ,则必须通过~/.vim/after/ftplugin/foo.vim:setlocal命令覆盖它(或完全禁用文件类型插件)。

tw上的:help表示设置了compatible时将其设置为0(禁用)。 compatible在一个地方,我们看不到它(后也许集nocompatible在源文件中的一个起点)?

您应该选择想要的:

  1. 通过插入换行符,让vim将文本格式设置为较短的行:可以通过设置textwidth(例如,在.vimrc set textwidth=30 )来实现。 然后,可以通过标记文本(可视模式)并键入gq来重新格式化文本。
  2. 保留所有行,但将它们显示为set wrap :将set wrap添加到.vimrc

暂无
暂无

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

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