On 2010-02-05, .b-o-b b-y-e-r-s wrote:
> I recently turned on filetype plugin in my vimrc:
> 
> :filetype plugin on
> 
> Currently, I have no filetype plugins installed in my .vim/ftplugin
> directory
> 
> Now when I edit text files I find the following setting is enabled:
> 
>    comments=:#
> 
> Is there any way to disable this auto-setting for text files? I don't
> want that particular feature, though I do hope to install some other
> filetype plugins.
> 
> I found I can simply do ":set comments=" and I'm all set. But adding
> this to .vimrc, even after :filetype plugin on, doesn't work, it is
> still set to comments=:#

Settings that are made according to file type are made when a buffer
is loaded with a file, a new buffer is created with a name, or the
file type of an existing buffer is set.  All of those events happen
after .vimrc is read, so filetype-dependent settings will override
settings made in .vimrc.

To find out where 'comments' is being set to ":#", execute

    :verbose set comments?

My guess is that the answer will be $VIMRUNTIME/ftplugin/conf.vim.

You may think you're editing "text files", but vim thinks you're
editing generic configuration files.  That is, they look like
generic configuration files to vim, so it sets 'filetype' to "conf"
and sources $VIMRUNTIME/ftplugin/conf.vim.

If the files you are editing didn't look to vim like a particular
file type, vim would not set 'filetype' and your .vimrc 'comments'
setting would not be overridden.

There are several ways to resolve this, depending on how you want
vim to behave when editing those files.

One is to tell vim that you think of that type of file as something
different than "conf".  Then you can specify exactly the settings
that are made or not made when you edit a file of that type.  If
that's what you want to do, we can cover that in another post.

Another is to tell vim that you don't want it to change any settings
at all when it detects a file of type "conf".  In that case, create
a file named conf.vim, put it in ~/.vim/ftplugin, and put in it this
line:

    let b:did_ftplugin = 1

That will prevent the contents of $VIMRUNTIME/ftplugin/conf.vim from
being executed.

Another is to tell vim that most of the settings it makes for "conf"
file types are fine but that you really want a different setting for
'comments'.  In that case, create a file named conf.vim, put it in
~/.vim/after/ftplugin, and put in it your 'comments' setting using
"setlocal" rather than "set", e.g.,

    setlocal comments=

That will set 'comments' back to the way you want it after
$VIMRUNTIME/ftplugin/conf.vim has set it.

HTH,
Gary


-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to