On 25/06/09 16:12, Alessandro Antonello wrote:
>
>> Hi All,
>>
>> I started VIM without giving the file name and started writing a C program.
>> After writing following lines
>>
>> #include<stdio.h>
>>
>> int main ()
>> {
>>      int i;
>>
>>      for (i = 0; i<  10; i++) {
>>          printf ("i=%d", i);
>>      }
>>      return 0;
>> }
>>
>>
>> I ran the command
>> :filetype detect
>> :set filetype
>> filetype=conf
>>
>> It detected the file as a configuration file.
>>
>> If I don't type the first line              #include<stdio.h>
>> then it is unable to detect the file type.
>>
>> I am not sure why is it not able to detect the file type.
>>
>> Any clues!!!!!!!!
>>
>> Thanks and Regards,
>> Prasad
>
> Almost all  file type detection  is made in  "filetype.vim" script in  your 
> VIM
> distribution.  Some of then reads the buffer to "find" the type of the file 
> you
> are working on.  Others  just trust the extension of the  file name.  C and 
> C++
> doesn't have a script to read the buffer  to find out what kind of the file 
> you
> are working on.  This isn't needed.  Read the content of the buffer is just 
> for
> types that can lead a confusion or are used by more than one syntax type.
>
> Regards.
> Alessandro

Yeah. Your vimrc should either source the vimrc_example.vim or include 
the lines

        filetype plugin on
        syntax on

(optionally with "indent" without quotes before "on" in the "filetype" 
line). Then every "detectable" file will be detected and highlighted. If 
you start an empty file without a name, it isn't "detectable" -- no 
highlighting. But either starting a file with

        :e foobar.c

or starting to edit it as [No Name] as I bet you did, then giving it a 
name with

        :saveas somestuff.c

will highlight it as C source without the need for any ":filetype" or 
":syntax" commands other than the ones in your vimrc (or in the 
vimrc_example.vim).


Best regards,
Tony.
-- 
A long-forgotten loved one will appear soon.  Buy the negatives at any
price.

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

Reply via email to