Disable auto indenting yet keep imaps
From Vim Tips Wiki
Tip 1039 • Previous Tip • Next Tip
Created: November 7, 2005 Complexity: basic Author: Yakov Lerner Minimum version: 6.0 Karma: 0/2 Imported from: Tip#1039
The 'set paste' command disables autoindenting, but the downside is that imaps (insertion-mode maps) do not work.
I needed imaps to work and autoindenting disabled, together.
This means I had to disable all autoindenting and 'set nopaste'. This combination turned out surprisingly difficult to grok. Finally I found the 6 relevant options, and the proper autocommand to resist persistent attempts of filetype-scripts to turn autoindenting on.
Here is the solution that finally worked for me:
" Begin disable-autoindent-with-nopaste stuff set noai noautoindent nocin nocindent nosi nosmartindent nopaste au BufWinEnter * :set noci nocindent indentexpr= indentkeys= map \a :call ShowAutoIndent()<cr> fu! ShowAutoIndent() 20verbose set ai? cin? si? paste? indentexpr? indentkeys? endfu
If indenting is still not disabled, you can diagnose the problem using \a, or :call ShowAutoIndent()<cr>. This will show you which script turned autoindenting back on. The 'correct' output (all autoindenting disabled) should look like this:
noautoindent nocindent nosmartindent nopaste indentexpr= indentkeys=
[edit] Comments
Categories: Review | VimTip | Indenting | Options
