History Report a problem
Article Edit this page Discussion

Disable auto indenting yet keep imaps

From Vim Tips Wiki

Jump to: navigation, search
 

Tip 1039Previous TipNext 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

 

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Disable auto indenting yet keep imaps"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation