新安装后,vim expandtab无法工作

2024-04-25 06:34:36 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

我没有安装插件什么的,为什么会坏掉?在

p.S.已经看过同样的静默,但它们是关于插件的,我并没有。 P、 注意到在:之后,vim不会根据cindent启动新行

:set paste之后仍然缩进代理。为什么会这样?在


Tags: columnsthelinetabspacesinsertwhenset
1条回答
网友
1楼 · 发布于 2024-04-25 06:34:36

set paste“打断”缩进。这就是它所能做的。这就是它起作用的原因。将文本粘贴到Vim中通常与键入每个字母是一样的。例如,打开一个包含一些文本的文件(在Vim中),并确保Vim处于正常模式。复制以下文本:d4dAhowdy。把它粘贴到Vim中。您将看到它删除了四行(d4d),在行尾(A)更改为插入模式,并输入howdy。粘贴到Vim中与键入字母是一样的事情;它不一定只是粘贴所有东西的方式。假设您键入:

if this:
that

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

^{pr2}$

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

相关问题 更多 >