Thursday, June 17, 2010

Re: How to test filetype in _vimrc

On 06/17/2010 12:51 PM, Roy Fulbright wrote:
>
>

>
>
>
> Date: Thu, 17 Jun 2010 11:23:28 -0400
> From: andrei.avk@gmail.com
> To: vim_use@googlegroups.com
> Subject: Re: How to test filetype in _vimrc
>
> On 06/17/2010 11:20 AM, Roy Fulbright wrote:
>>
>> I am trying to test for filetype '.bat' in _vimrc and set syntax off. I tried adding the following to _vimrc but it does not work:
>>
>> 
>>
>> if v:fname_in =~ '.bat$'
>>
>>    syntax off
>>
>> end if
>>
>> 
>>
>> I echoed v:fname_in and it was NULL. I also echoed v:fname_out and it was also NULL. That seems strange. Can someone offer a solution?
>>
>> 
>>
>> Thanks,
>>
>> Roy Fulbright
>>
>
> What you want is something like this:
>
> :au BufNew,BufRead *.bat :syntax off
>
> see :help :au
>
>    -ak
>
> Thanks for the reply. I tried using the 'au' command you mentioned, but syntax still remains ON when I open a '.bat' file. This is one of those things I know should not be this difficult, yet the solution remains elusive.


I remember there was a thread about this not too long ago.. I didn't
read it though so I don't remember the solution. I think it also depends
on whether you just want to open a single file, edit and close or if you
want to open a .bat file within single session and have it without
highlight while other files are with highlight. If you don't need stuff
like filetype indentation you can also change that autocommand to do
:set ft=

(i.e. set filetype to nothing). Then there will be no colours but other
files will still have them.

   -ak

--
 Python plugins for vim: outliner, todo list, project manager, calendar,
 expenses tracker, sortable table, and more |
 http://lightbird.net/pysuite/


No comments: