Sunday, December 25, 2011

Re: why is Vim coloring text in txt files?

Tony Mechelynck wrote the following on 26.12.2011 04:47

Hello

>> Thanks Thilo.
>>
>> I found the Generic configuration code in my C:\Program Files (x86)\Vim
>> \vim73\filetype.vim
>> Where in the file should the local configuration code (below) be
>> placed?
>>
>> " txt
>> autocmd BufNewFile,BufRead
>> \ *.txt,
>> \*README*
>> \ setl ft=text
>>
>> wolfv

Sorry i am not familar with the windows version of vim. So you should follow
Tonys hint. But i want to share cool little feature i just figured:

,----[ ft=text ]---------------------------

" txt
autocmd BufNewFile,BufRead
\ *.txt,
\\c*README*
\ setl ft=text
`---------------------------------------------

The nice thing here is the additional '\c' which means 'ignore case'. At least i
didn't know until today that this can be used there, too. Nice.


> On Windows, it could either be part of ~/vimfiles/filetype.vim, after
>
> if exists("did_load_filetypes")
> finish
> endif

Personly i would leave this out as i sometimes deliberately overwrite defaults
from '$VIMRUNTYME/filetype.vim'. I instead use:

,----[ ~/.vim/ftdetect/filetype.vim ]-------

" only spend time on this once
if exists("b:did_load_filetypes_user")
finish
endif
let b:did_load_filetypes_user = 1
`---------------------------------------------

Oh and yes you can have '~/.vim/ftdetect/text.vim', '~/.vim/ftdetect/foo.vim'
and '~/.vim/ftdetect/bar.vim' or just throw everything in
'~/.vim/ftdetect/filetype.vim' as i do. As long as the file ends with '.vim' it
should work.
Again i do not know where this directory is on windows, most probably somewhere
below '%appdata%'. 'set runtimepath?' should help here. Use the first directory
as starting point.

> and possibly together with other user-defined filetype detection
> autocommands (BTW do not set that did_load_filetypes variable, it is set
> by $VIMRUNTYME/filetype.vim), or else it could be all of
> ~/vimfiles/ftdetect/text.vim (with paths shown as they could be used in
> Vim but not in other Windows programs). Or you could replace ~/vimfiles/
> by $VIM/vimfiles/ in either of these paths if you wanted these
> customizations to apply to all users (all login names) on your computer.
>
> See
> :help new-filetype
>
> See also
> :help 'runtimepath'
>
> about the different default paths on Windows ("PC") vs. Unix/Linux/OSX
> ("Unix").
>
>
> Best regards,
> Tony.


--
Regards,
Thilo

4096R/0xC70B1A8F
721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F


--
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