Modify the vim configuration in ubuntu and treat the. inc suffix file dynamically as different files.

Source: Internet
Author: User
Tags setf
Search for the filetype in the vim installation directory. the vim file is/usr/share/vim/vim72/filetype. vim opened it to search for inc. I found the following: 1360-1365 was added later. From 1347, we can see that the. inc file is used as a format to parse the highlighted syntax followed by a function...

 

Search for the filetype. vim file in the vim installation directory

 

My options are/usr/share/vim/vim72/filetype. vim.

 

Open it and search for inc

 

I found the following: 1360-1365 was added later.

 

From 1347, we can see that the. inc file is used as a format to parse the highlighted syntax.

 

The following is a function call s: FTinc ()

 

It means that the first three rows of the file, getline (1). getline (2). getline (3), find that there is a XX string.

 

In the first three rows, '/\ ** filetype * = * cpp * \ */' or '/\ ** filetype * = * c * \ */' appears *\*/'' # * filetype * = * make * 'is used as the file.

 

Of course, if the above problem occurs at the same time, the last occurrence prevails-the state machine.

 

I hope to help you.

 

1346 "Povray, PHP or assembly

1347 au BufNewFile, BufRead *. inc call s: FTinc ()

1348

1349 func! S: FTinc ()

1350 if exists ("g: filetype_inc ")

1351 exe "setf". g: filetype_inc

1352 else

1353 let lines = getline (1). getline (2). getline (3)

1354 if lines = ~? "Perlscript"

1355 setf aspperl

1356 elseif lines = ~ "<%"

1357 setf aspvbs

1358 elseif lines = ~ "

1359 setf php

1360 elseif lines = ~ '/\ ** Filetype * = * cpp *\*/'

1361 setf cpp

1362 elseif lines = ~ '/\ ** Filetype * = * c *\*/'

1363 setf c

1364 elseif lines = ~ '# * Filetype * = * make *'

1365 setf make

1366 else

1367 call s: FTasmsyntax ()

1368 if exists ("B: asmsyntax ")

1369 exe "setf". fnameescape (B: asmsyntax)

1370 else

1371 setf pov

1372 endif

1373 endif

1374 endif

1375 endfunc

 

Author dengxu11

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.