I have set autoindentation, but vim somehow ignores it because :set autoindent? says noautoindent however the last file to have set autoindent is really my vimrc file according to :verbose set autoindent?

        Last set from ~/myScripts/.vim/vimrc line 10

However set autoindent is really in my vimrc file :

$ grep -n autoindent ~/myScripts/.vim/vimrc
10:set autoindent

EDIT0 : Lines between 9 and 11 of my ~/myScripts/.vim/vimrc file :

$ sed -n 9,11p ~/myScripts/.vim/vimrc
set nohls
set autoindent
set noexpandtab tabstop=4 shiftwidth=4

EDIT1 : ~/.vim/vimrc is pointing to my ~/myScripts/.vim/vimrc :

$ readlink -f ~/.vim/vimrc

EDIT2: Thanks to filbranden, it seems that paste and autoindent are mutually exclusive :

The 'autoindent' option is reset when the 'paste' option is set and restored when 'paste' is reset.

Here's what I had in my ~/myScripts/.vim/vimrc :

$ egrep -n "^set ((no)?autoindent|(no)?paste)" ~/myScripts/.vim/vimrc
10:set autoindent
67:set paste
  • What's on line 11? Is it something starting with \! or something like that?
    – filbranden
    May 27, 2020 at 13:03
  • @filbranden See my EDIT0
    – SebMa
    May 27, 2020 at 13:05
  • Odd... How are you sourcing your vimrc from that file? Can you reproduce that with a one-line vimrc file with only that line?
    – filbranden
    May 27, 2020 at 13:08
  • @filbranden See my EDIT1
    – SebMa
    May 27, 2020 at 13:19
  • 1
    I guess you have :set paste? enabled! Do :set nopaste and that should restore autoindent to its original state!
    – filbranden
    May 27, 2020 at 13:29

1 Answer 1


This is happening due to :set paste.

As :help 'autoindent' says:

The 'autoindent' option is reset when the 'paste' option is set and restored when 'paste' is reset.

It turns out this affects the way :set ai? reports the setting, even though :verbose still keeps showing the source for the setting coming from the same line:

:verbose set ai?
    Last set from ~/.vim/plugged/vim-sensible/plugin/sensible.vim line 20
:set paste
:verbose set ai?
    Last set from ~/.vim/plugged/vim-sensible/plugin/sensible.vim line 20

So just make sure you don't have 'paste' enabled. It shouldn't be enabled during normal operation anyways...

If you want a helper to manage enabling 'paste' when you're pasting external text into Vim, I recommend vim-unimpaired which defines a yop mapping (together with [op and ]op). From :help yop:

A toggle has not been provided for 'paste' because the typical use case of wrapping of a solitary insertion is inefficient: You toggle twice, but you only paste once (YOPO). Instead, press [op, ]op, or yop to invoke O, o, or 0C with 'paste' already set. Leaving insert mode sets 'nopaste' automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.