created February 9, 2006 · complexity basic · author Alvin · version 6.0
It's quite hard to find how to really turn off all auto indentation.
I tried to place "set noai" in vimrc, but the auto-filetype-detecting feature will override "set noai" if your file has for instance ".cpp" or ".java" common extension.
I've checked in fact the default setting of vim is 'noai', therefore we don't need 'set noai'.
My solution is placing these in vimrc:
filetype plugin indent off filetype indent off"
Comments
Just set "pastetoggle". For example,
:set pastetoggle=<F11>
Now, hitting F11 will allow you to paste without indenting. Hitting it again will return you to normal editing mode.
Just don't put "filetype indent plugin on" in your vimrc and you don't need to put "filetype indent plugin off" there. Autoindentation is off by default AFAIK.
I was using the excellent XMLFolding.vim script, editing xml, plus the matchit.vim script, so I can use % to visit tag boundaries. But I didn't like the automatic indent. I found that this turned it off for me while editing and xml file.
:set indentexpr=
However, now I'm finding that it may be better to leave it on!
- filetype plugin and filetype indent are off by default (unfortunately), as noted above
- they are both recommended settings, which can improve a lot indenting and editing in general of files with such a filetype
- if an indent file for a particular filetype is not wanted, it can be overridden by a custom ftplugin (see :help after and :help after-directory).
TO DO
- I'll try to return and do some cleaning up of this tip. Meanwhile, here are some rough notes.
- The stuff about "pastetoggle" is intended to address an indenting problem that can occur when pasting text into a terminal. See Pastetoggle. It is not relevant here.
- There is at least one other confused tip on this topic: How to stop auto indenting (need to fix/merge).
- This tip gives bad advice. See the talk page and its reference to the discussion on vim_use. Confusing stuff! JohnBeckett 22:58, 16 June 2009 (UTC)