简体   繁体   English

新安装后,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

Somehow after reinstallation of my arch linux, vim stoped work poperly. 重新安装我的arch linux之后,vim突然停止工作。 After doing the same I did couple days ago with old system - now python complains about indentation. 经过几天前我对旧系统所做的相同操作后,现在python抱怨缩进。

I have no installed plugins or whatever, why does this broke? 我没有安装任何插件,为什么会这样呢?

PS already viewed same quiestions, but them was about plugins, which I doesn't have. PS已经查看过相同的问题,但它们与插件有关,而我没有。 PS Noticed that after : vim won't start newline according cindent PS注意:之后: vim不会根据cindent启动换行符

Still indentation brokes after :set paste . :set paste之后,仍然没有压痕。 Why this happens? 为什么会这样?

set paste "breaks" the indentation. set paste “中断”缩进。 That is all it does. 这就是全部。 That is the reason it works. 这就是它起作用的原因。 Pasting text into Vim would normally be the same thing as just typing each letter. 将文本粘贴到Vim中通常与输入每个字母相同。 For example, open a file that has some text in it (in Vim), and make sure that Vim is in normal mode. 例如,打开一个包含一些文本的文件(在Vim中),并确保Vim处于正常模式。 Copy the following text: d4dAhowdy . 复制以下文本: d4dAhowdy Paste it into Vim. 将其粘贴到Vim中。 You will see that it deletes four lines ( d4d ), changes to insert mode at the end of the line ( A ), and types howdy . 您将看到它删除了四行( d4d ),在行尾( A )更改为插入模式,然后键入howdy Pasting into Vim is the same thing as typing the letters; 粘贴到Vim中与输入字母相同。 it does not necessarily just paste everything exactly how it comes. 它不一定只是完全粘贴所有内容。 Let's say you type: 假设您输入:

if this:
that

Once you hit Enter after if this: , Vim would indent the line, so that code would actually appear as: if this:按Enter键, if this: Vim会将行缩进,因此该代码实际上将显示为:

if this:
    that

Using set paste turns that off so that when you paste that code in (with the indentation included), Vim does not auto-indent and everything shows up normally. 使用set paste将其关闭,以便在粘贴该代码(包括缩进)时,Vim不会自动缩进,并且一切都可以正常显示。 If you were to set nopaste and then paste the above un indented code, Vim would indent it for you. 如果要set nopaste然后粘贴上面缩进的代码,Vim会为您缩进它。

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

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