Vim autoindent在8.0.1097中不起作用

时间:2017-09-22 00:50:49

标签: vim

我在vim 8.0.1097和vim 7.4上有相同的vim设置,但自动行为不同:

在vim 8中:

if [ "$u" != "root" ]
    then
        a
        b
        c
        fi

在Vim 7中它运行良好。

Vim 8 :set显示:

--- Options ---
  autoindent          commentstring=#%s   hidden              incsearch           matchtime=2         scrolloff=7         smartcase           tabstop=4           ttymouse=xterm      t_vb=
  background=dark     expandtab           history=700         laststatus=2        modified            shiftwidth=4        smarttab            textwidth=79        viminfo=%,'20,"50
  cindent             filetype=sh         hlsearch            lazyredraw          ruler               showmatch         noswapfile            timeoutlen=500      wildmenu
  cmdheight=2         helplang=en         ignorecase          linebreak           scroll=31           showtabline=2       syntax=sh           ttyfast           nowritebackup
  backspace=eol,start,indent
  completeopt=menuone,longest,preview
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,latin1
  fileformats=unix,dos,mac
  grepprg=grep -nH $*
  guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
  indentexpr=GetShIndent()
  indentkeys=0{,0},!^F,o,O,e,0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;&,0=fin,0=fil,0=fip,0=fir,0=fix
  runtimepath=~/.vim,~/.vim/bundle/ctrlp,~/.vim/bundle/indentLine,~/.vim/bundle/javacomplete,~/.vim/bundle/jedi-vim,~/.vim/bundle/nerdcommenter,~/.vim/bundle/nerdtree,~/.vim/bundle/supertab,~/.vim/bundle/syntastic,~/.vim/bundle/vim-fugit
ive,~/.vim/bundle/vim-repeat,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-tmux-navigator,~/.vim/bundle/vim-trailing-whitespace,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,~/.vim/bundle/jedi-vim/after,~/.vim
/bundle/indentLine/after,~/.vim/after
  statusline= %{HasPaste()}%F%m%r%h %w  CWD: %r%{getcwd()}%h   Line: %l Column: %c
  switchbuf=useopen,usetab,newtab
  whichwrap=b,s,<,>,h,l
  wildignore=*.o,*~,*.pyc

vim 7.4 :set显示:

--- Options ---
  autoindent          commentstring=#%s   filetype=sh         hlsearch            lazyredraw          scroll=31           showtabline=2       syntax=sh           ttyfast           nowritebackup
  background=dark     cscopetag           helplang=en         ignorecase          linebreak           scrolloff=7         smartcase           tabstop=4           ttymouse=xterm      t_vb=
  cindent             cscopeverbose       hidden              incsearch           matchtime=2         shiftwidth=4        smarttab            textwidth=79        viminfo=%,'20,"50
  cmdheight=2         expandtab           history=700         laststatus=2        ruler               showmatch         noswapfile            timeoutlen=500      wildmenu
  backspace=eol,start,indent
  completeopt=menuone,longest,preview
  cscopeprg=/usr/bin/cscope
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,latin1
  fileformats=unix,dos,mac
  grepprg=grep -nH $*
  guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
  indentexpr=GetShIndent()
  indentkeys=0{,0},!^F,o,O,e,0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,),0=;;,0=;&,0=fin,0=fil,0=fip,0=fir,0=fix
  iskeyword=@,48-57,_,192-255,.
  runtimepath=~/.vim,~/.vim/bundle/ctrlp,~/.vim/bundle/indentLine,~/.vim/bundle/javacomplete,~/.vim/bundle/jedi-vim,~/.vim/bundle/nerdcommenter,~/.vim/bundle/nerdtree,~/.vim/bundle/supertab,~/.vim/bundle/syntastic,~/.vim/bundle/vim-fugit
ive,~/.vim/bundle/vim-repeat,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-tmux-navigator,~/.vim/bundle/vim-trailing-whitespace,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,~/.vim/bundle/jedi-vim/after,~/.vim
/bundle/indentLine/after,~/.vim/after
  statusline= %{HasPaste()}%F%m%r%h %w  CWD: %r%{getcwd()}%h   Line: %l Column: %c
  switchbuf=useopen,usetab,newtab
  whichwrap=b,s,<,>,h,l
  wildignore=*.o,*~,*.pyc

区别在于:

     --- Options ---
-      autoindent          commentstring=#%s   hidden              incsearch           matchtime=2         scrolloff=7         smartcase           tabstop=4           ttymouse=xterm      t_vb=
-      background=dark     expandtab           history=700         laststatus=2        modified            shiftwidth=4        smarttab            textwidth=79        viminfo=%,'20,"50
-      cindent             filetype=sh         hlsearch            lazyredraw          ruler               showmatch         noswapfile            timeoutlen=500      wildmenu
-      cmdheight=2         helplang=en         ignorecase          linebreak           scroll=31           showtabline=2       syntax=sh           ttyfast           nowritebackup
+      autoindent          commentstring=#%s   filetype=sh         hlsearch            lazyredraw          scroll=31           showtabline=2       syntax=sh           ttyfast           nowritebackup
+      background=dark     cscopetag           helplang=en         ignorecase          linebreak           scrolloff=7         smartcase           tabstop=4           ttymouse=xterm      t_vb=
+      cindent             cscopeverbose       hidden              incsearch           matchtime=2         shiftwidth=4        smarttab            textwidth=79        viminfo=%,'20,"50
+      cmdheight=2         expandtab           history=700         laststatus=2        ruler               showmatch         noswapfile            timeoutlen=500      wildmenu
       backspace=eol,start,indent
       completeopt=menuone,longest,preview
+      cscopeprg=/usr/bin/cscope
       fileencoding=utf-8
       fileencodings=ucs-bom,utf-8,latin1
       fileformats=unix,dos,mac
       grepprg=grep -nH $*
       guicursor=n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block,a:blinkon0
       indentexpr=GetShIndent()
-      indentkeys=0{,0},!^F,o,O,e,0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;&,0=fin,0=fil,0=fip,0=fir,0=fix
+      indentkeys=0{,0},!^F,o,O,e,0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,),0=;;,0=;&,0=fin,0=fil,0=fip,0=fir,0=fix
+      iskeyword=@,48-57,_,192-255,.
       runtimepath=~/.vim,~/.vim/bundle/ctrlp,~/.vim/bundle/indentLine,~/.vim/bundle/javacomplete,~/.vim/bundle/jedi-vim,~/.vim/bundle/nerdcommenter,~/.vim/bundle/nerdtree,~/.vim/bundle/supertab,~/.vim/bundle/syntastic,~/.vim/bundle/vim-fugit
-    ive,~/.vim/bundle/vim-repeat,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-tmux-navigator,~/.vim/bundle/vim-trailing-whitespace,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,~/.vim/bundle/jedi-vim/after,~/.vim
+    ive,~/.vim/bundle/vim-repeat,~/.vim/bundle/vim-surround,~/.vim/bundle/vim-tmux-navigator,~/.vim/bundle/vim-trailing-whitespace,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,~/.vim/bundle/jedi-vim/after,~/.vim
     /bundle/indentLine/after,~/.vim/after
       statusline= %{HasPaste()}%F%m%r%h %w  CWD: %r%{getcwd()}%h   Line: %l Column: %c
       switchbuf=useopen,usetab,newtab

前4个差异实际上只是按不同顺序排列,项目数量相同。我试图手动设置cscopeprg以匹配vim 7.4的值,它没有任何区别。

我不明白我的vim配置可能导致这种行为的哪一部分。

我的插件列表(全部最新): ctrlp indentLine javacomplete jedi-vim nerdcommenter nerdtree supertab syntastic vim-fugitive vim-repeat vim-surround vim-tmux-navigator vim-trailing-whitespace

我也尝试删除所有插件,vim 8仍然出现故障。

使用降级方法,我将vim重新安装到8.0.662和8.0.1030,打字时的缩进工作完美。我认为较新版本的vim存在一个错误。

1 个答案:

答案 0 :(得分:0)

这种行为确实是由于版本bug中引入了Vim中的8.0.1041,并且已在版本8.0.1154中得到修复。您应该能够通过从上游升级到最新版本来解决此问题。