vim expandtab 在新安装后不起作用

vim expandtab doesn't work after new installation

let mapleader = "," 

set number

set textwidth=79  " lines longer than 79 columns will be broken
set shiftwidth=4  " operation >> indents 4 columns; << unindents 4 columns
set tabstop=4     " a hard TAB displays as 4 columns
set expandtab     " insert spaces when hitting TABs
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE
set shiftround    " round indent to multiple of 'shiftwidth'
set cindent       " align the new line indent with the previous line

set nobackup
set nowritebackup
set noswapfile

vnoremap < <gv " continue visual selecting after shiftwidh
vnoremap > >gv 

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

nnoremap j gj
nnoremap k gk

nnoremap <Leader>r :w \| !clear && ./%<CR>
command W w !sudo tee % > /dev/null
noremap <silent><Leader>/ :nohls<CR>

set clipboard=unnamedplus
set paste
set ignorecase

重新安装我的 arch linux 后,vim 突然停止工作。 在几天前我用旧系统做了同样的事情之后 - 现在 python 抱怨缩进。

我没有安装任何插件,为什么会坏掉?

P.S。已经查看过相同的问题,但它们是关于插件的,我没有。 P.S。注意到 : vim 之后不会根据 cindent

开始换行

:set paste 后仍然有缩进中断。为什么会这样?

set paste "breaks" 缩进。这就是它所做的一切。这就是它起作用的原因。将文本粘贴到 Vim 通常与键入每个字母是一回事。例如,打开一个包含一些文本的文件(在 Vim 中),并确保 Vim 处于正常模式。复制以下文本:d4dAhowdy。将其粘贴到 Vim。您将看到它删除了四行 (d4d),在行尾更改为插入模式 (A),并键入 howdy。粘贴到 Vim 与键入字母相同;它不一定只是准确地粘贴所有内容。假设您键入:

if this:
that

一旦您在 if this: 之后按 Enter,Vim 将缩进该行,因此代码实际上显示为:

if this:
    that

使用 set paste 关闭它,这样当您粘贴该代码(包括缩进)时,Vim 不会自动缩进,一切都会正常显示。如果您要 set nopaste 然后粘贴上面的 un 缩进代码,Vim 会为您缩进。