简体   繁体   中英

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. After doing the same I did couple days ago with old system - now python complains about indentation.

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 Noticed that after : vim won't start newline according cindent

Still indentation brokes after :set paste . Why this happens?

set paste "breaks" the indentation. 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. For example, open a file that has some text in it (in Vim), and make sure that Vim is in normal mode. Copy the following text: d4dAhowdy . Paste it into Vim. You will see that it deletes four lines ( d4d ), changes to insert mode at the end of the line ( A ), and types howdy . Pasting into Vim is the same thing as typing the letters; 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:
    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. If you were to set nopaste and then paste the above un indented code, Vim would indent it for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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