Best way to disable runtime/indent/html.vim

65 views
Skip to first unread message

Suresh Govindachar

unread,
Jun 7, 2009, 7:43:05 PM6/7/09
to vim...@googlegroups.com

Which is the preferred way to diable runtime/indent/html.vim (instead of just renaming the file)?


Matt Wozniski

unread,
Jun 7, 2009, 11:04:29 PM6/7/09
to vim...@googlegroups.com
On Sun, Jun 7, 2009 at 7:43 PM, Suresh Govindachar wrote:
>
> Which is the preferred way to diable runtime/indent/html.vim (instead
> of just renaming the file)?

A well-behaved indent script has a check at the top of it to see whether
the buffer already has some sort of script-based indenting enabled, and
if so does nothing. For example, indent/html.vim has this:

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1

So, to disable it, you can just make a ~/.vim/indent/html.vim (or
~/vimfiles/indent/html.vim on Windows) and put in it the single line

let b:did_indent = 1

It will be loaded before the system-wide one (because the runtime files
in $HOME take precedence) and stop the system-wide one from doing
anything (because the system-wide one checks that variable).

~Matt

Ben Fritz

unread,
Jun 8, 2009, 10:34:39 AM6/8/09
to vim_use


On Jun 7, 6:43 pm, "Suresh Govindachar" <sgovindac...@yahoo.com>
wrote:
> Which is the preferred way to diable runtime/indent/html.vim (instead of just renaming the file)?

Matt has given you a good way to disable the indent script for a
single filetype. If you instead want to disable ALL indent scripts,
don't turn them on in the first place. You probably have something
like:

filetype indent plugin on

or

filetype indent on

in your .vimrc. Remove the "indent" keyword and none of your files
will have the vimscript indent rules applied.

Matt Wozniski

unread,
Jun 8, 2009, 12:58:07 PM6/8/09
to vim...@googlegroups.com
On Mon, Jun 8, 2009 at 10:34 AM, Ben Fritz wrote:

>
> On Jun 7, 6:43 pm, "Suresh Govindachar" wrote:
>> Which is the preferred way to diable runtime/indent/html.vim (instead of just renaming the file)?
>
> Matt has given you a good way to disable the indent script for a
> single filetype. If you instead want to disable ALL indent scripts,
> don't turn them on in the first place. You probably have something
> like:
>
> filetype indent plugin on
>
> or
>
> filetype indent on
>
> in your .vimrc. Remove the "indent" keyword and none of your files
> will have the vimscript indent rules applied.

<pedantic>

Note that if you have a naughty distro that puts "filetype plugin
indent on" in the systemwide vimrc, that won't be enough - you'll need
to instead do

filetype off
filetype plugin on

</pedantic>

~Matt

Tony Mechelynck

unread,
Jun 14, 2009, 1:42:23 PM6/14/09
to vim...@googlegroups.com

That won't be enough, because ":filetype off" remembers your settings
for later: it is not the same as ":filetype plugin indent off".

Rather than the two commands above, you should use

filetype indent off

The same applies if you source the vimrc_example.vim (which has a
"filetype plugin indent on" somewhere in it): just unset
filetype-dependent indenting just after sourcing the vimrc_example.vim then.

See ":help :filetype-overview"


Best regards,
Tony.
--
He hadn't a single redeeming vice.
-- Oscar Wilde

Tony Mechelynck

unread,
Jun 14, 2009, 1:50:43 PM6/14/09
to vim...@googlegroups.com

Yes, Suresh, this is the right way to disable filetype-specific
indenting for a single filetype.

Renaming the $VIMRUNTIME/indent/html.vim, or editing it in-place, won't
work, because as soon as you bring your runtime files up-to-date
(something which you should do often), you'll get a fresh copy of the
original script, with all your changes removed, and all that without a
warning message to you.


Best regards,
Tony.
--
Decisions of the judges will be final unless shouted down by a really
overwhelming majority of the crowd present. Abusive and obscene
language may not be used by contestants when addressing members of the
judging panel, or, conversely, by members of the judging panel when
addressing contestants (unless struck by a boomerang).
-- Mudgeeraba Creek Emu-Riding and Boomerang-Throwing
Assoc.

Reply all
Reply to author
Forward
0 new messages