gpt4 book ai didi

vim: smartindent (或 cindent) 被激活但不工作

转载 作者:行者123 更新时间:2023-12-01 08:32:26 25 4
gpt4 key购买 nike

Vim 不会自动缩进我正在处理的 C 源文件,尽管它声称当我键入:放命令。当我输入一些代码时什么都没有发生。比如写

int main()
{
return 0;
}

“返回 0;”语句留在左边。但是,如果我键入“=G”命令,我的文件会缩进。

这是我的配置:

  • ubuntu 13.04
  • vim 7.3.547 + vim 脚本

vimrc 分为/etc/vim/vimrc 和 ~/.vimrc。拼接内容如下:

runtime! debian.vim

if has("syntax")
syntax on
endif

set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

if has("autocmd")
filetype plugin indent on
endif

set showcmd
set showmatch

if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif

""""""" now this is ~/.vimrc """""

set runtimepath+=,/usr/share/vim-scripts

set autoindent
set noexpandtab

" create ~<file> when saving modifications to <file>
set backup

" preserve source's format when pasting
set paste

" disable mouse usage
set mouse=

" colors
set t_Co=256
colorscheme mustang

set hlsearch

set number

set cursorline

if has("statusline")
hi User1 ctermbg=red cterm=bold,reverse
hi User2 ctermbg=darkblue cterm=bold,reverse
hi User3 ctermbg=darkred cterm=bold,reverse
hi User4 ctermbg=brown cterm=bold,reverse

set laststatus=2
set statusline=%h%f\ %y\ %1*%r%*%1*%m%*%=[col:%2*%c%*]\ [line:%3*%.6l%*/%4*%.6L%*\ -\ %p%%]
endif

set spellsuggest=5

match Error /\s\+$/

你有什么想法吗?

非常感谢您的帮助。

皮埃尔

最佳答案

在将 set paste 添加到 ~/.vimrc 之前,您应该阅读 :help paste:

When the 'paste' option is switched on (also when it was already on):
... skipped ...
- 'autoindent' is reset
... skipped ...
These options keep their value, but their effect is disabled:
... skipped ...
- 'cindent'

'paste' 非常有毒,应该永远添加到一个人的 ~/.vimrc 中。请参阅 :help pastetoggle 和/或改用 p

关于vim: smartindent (或 cindent) 被激活但不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17104675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com