Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #1039 - Disable auto indenting yet keep imaps

Created: November 7, 2005 5:35 Complexity: basic Author: Yakov Lerner Version: 6.0 Karma: 0/2 Imported from: Tip#1039

The 'set paste' disables autoindenting, but the downside

is that imaps (insertion-mode maps) do not work.


I needed the imap-s to work *and* autoindenting disabled, together.


This means I had to disable all autoindenting *and* have 'set nopaste'.

This combination turned out surprisingly difficult to grok. Finally I

found the 6 relevant options, and the proper autocommand to

resists persistent attempts of filetype-scripts to turn the 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

" }}} disable-autoindent-with-nopaste


If indenting is *still* not disabled, you can diagnose the problem

using the \a, or :call ShowAutoIndent()<cr>. This will show you

which script turned autoindenting back on.


The 'correct' output (all autoindenting disabled) shall look like this:

noautoindent 
nocindent 
nosmartindent 
nopaste 
indentexpr= 
indentkeys=

Comments

Advertisement