Monday, December 26, 2011

Re: why is Vim coloring text in txt files?

On 26/12/11 10:32, Thilo Six wrote:
> Tony Mechelynck wrote the following on 26.12.2011 10:10
>
> Hello Tony,
>
> -- <snip> --
>>>> if exists("did_load_filetypes")
>>>> finish
>>>> endif
>>>
>>> Personly i would leave this out as i sometimes deliberately overwrite defaults
>>
>> So what? $VIMRUNTIME/filetype.vim sets its filetypes by :setfiletype,
>> which does nothing if the filetype is already set. So you can override
>> them by setting the filetype in ~/vimfiles/filetype.vim (for Windows) or
>> ~/.vim/filetype.vim (for Unix) which is sourced immediately before
>> $VIMRUNTIME/filetype.vim.
> -- <snip> --
>
> With the above snipped in '~/.vim/filetype.vim' overriding settings from
> '$VIMRUNTIME/filetype.vim' will NEVER happen (even when setl is stronger then
> setf) when '$VIMRUNTIME/filetype.vim' is sourced prior to '~/.vim/filetype.vim'.

It is not (as I saw, after writing this, that you mention it below). Vim
uses the equivalent of ":runtime! filetype.vim" to source it, and that
is guaranteed to source the files in the order of the 'runtimepath'
directories, i.e., on Unix:

1. ~/.vim/filetype.vim
2. $VIM/vimfiles/filetype.vim
3. $VIMRUNTIME/filetype.vim
4. $VIM/vimfiles/after/filetype.vim
5. ~/.vim/after/filetype.vim

or on Windows:

1. ~/vimfiles/filetype.vim
2. $VIM/vimfiles/filetype.vim
3. $VIMRUNTIME/filetype.vim
4. $VIM/vimfiles/after/filetype.vim
5. ~/vimfiles/after/filetype.vim

This order is intentional, and it is followed whenever Vim sources an
internal runtime script: it means that a local sysadmin can override the
Vim defaults for his system, and that every user can override for his
own use what the sysadmin chose for the whole installation.

>
> But it occurred to me that vims default is to source '~/.vim/filetype.vim' prior
> to '$VIMRUNTIME/filetype.vim' as you also mention above.
>
> There are lots of ways to shot one self in the feet. Choose the one that suits
> you best.
>

One of them that I'm not going to use is reversing the order of the
'runtimepath' directories while there are intentionally separate
"before" and "after" directories. If you want me to show you how to
shoot yourself in the foot by using Vim in unsupported ways, just speak
up (but I'd rather say how _not_ to shoot oneself in the foot): Vim is
not the kind of software which you can only use the way Mommy decided,
with only an intentionally limited set of features and only a single
padlocked manner of doing every single thing that it can do; for that,
what you need is Notepad. Vim has a lot of customizable features, maybe
more than you would wish, but I probably set them otherwise than you do,
and we are both happy. But some of them are not meant to be used in
foolish ways: you should not set 'term' to "pcterm" when running on an
xterm, you should not reverse the order of 'runtimepath' directories,
you should not manually set 'filetype' to "css" while editing a C source
module, you should not try to compile Vim with Borland C using the
src/make_mvc.mak makefile; and so on.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
256. You are able to write down over 250 symptoms of being an internet
addict, even though they only asked for 101.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment