selectively disable filetype indent

9 views
Skip to first unread message

Rene de Zwart

unread,
Nov 9, 2009, 2:54:58 AM11/9/09
to v...@vim.org
I wrote a plugin for assisting in (x)(ht)(x)ml editing.
However when
filetype indent on
is specified it messes up some actions in my plugin
e.g.
\t\t<html>
becomes
<html>
\t\t|
</html>
AND I Expect it to become
\t\t<html>
\t\t\t
\t\t<html>

I used filetype indent off in my plugin. Which is global and not localized
to the buffer. It works but the side effects are to much.

Has someone a solution?

Thanks Rene


Maxim Kim

unread,
Nov 9, 2009, 3:47:19 AM11/9/09
to vim_use
What about setting indent expression to nothing?
'setlocal indentexpr='

You can add it to your filetype or autocmd.

Best wishes,
Maxim.

Rene de Zwart

unread,
Nov 9, 2009, 5:08:22 AM11/9/09
to vim...@googlegroups.com
Fortunately the indent plugin runs after the ftplugin and over write the
index expression.

I even did
let b:did_indent = 1
to no avail.

What you can do is make .vim/indent/html.vim with
let b:did_indent = 1
That does stop vim72/indent/html.vim from loading

Rene


Gary Johnson

unread,
Nov 9, 2009, 11:54:07 AM11/9/09
to vim...@googlegroups.com

To turn off indenting for a particular file type, create your own
indent plugin for that file type containing only this line:

let b:did_indent = 1

For HTML, for example, the name of your indent plugin on Unix would
be

~/.vim/indent/html.vim

See

:help 30.3

Regards,
Gary


Tony Mechelynck

unread,
Dec 3, 2009, 11:07:28 PM12/3/09
to vim...@googlegroups.com, Rene de Zwart
To set indentation off on only a few filetypes

Add to your plugin a script containing

setlocal indentexpr= nocindent nolisp

and copy it to (or source it from) xml.vim, xhtml.vim and html.vim in
the directory ~/.vim/after/indent/ (on Unix) or ~/vimfiles/after/indent/
(on Windows). Of course, if these directories don't exist yet, create them.

Usually only one of the three is significant for any given filetype, but
putting them all three makes it applicable to any filetype where you
want to disable filetype-related indenting.

'autoindent' and/or 'smartindent' should probably be handled globally in
your vimrc anyway.


Best regards,
Tony.
--
The government [is] extremely fond of amassing great quantities of
statistics. These are raised to the nth degree, the cube roots are
extracted, and the results are arranged into elaborate and impressive
displays. What must be kept ever in mind, however, is that in every
case, the figures are first put down by a village watchman, and he puts
down anything he damn well pleases.
-- Sir Josiah Stamp
Reply all
Reply to author
Forward
0 new messages