On Wed, November 4, 2009 8:40 am, Gary Johnson wrote:
> On 2009-11-04, James Vega wrote:
>> I think this is referring to changing the filetype for a buffer, not
>> changing the syntax highlighting rules.
>
> OH.  I see now.  Thanks.
>
> If that's the case, then executing
>
>     :set ft=<filetype>
>
> where the set of <filetype> values can be found from
>
>     :!ls $VIMRUNTIME/syntax
>
> seems pretty simple to me.  Yes, I realize that's not nearly as
> clear and straightforward as selecting the file type from a menu,
> but a user should very rarely need to select the file type manually;
> Vim should almost always be able to determine the file type
> automatically.

How about something like this:

if !exists("s:ftlist")
    let s:ftlist=map(split(globpath(&rtp, "**/syntax/*.vim"), "\n"),
'fnamemodify(v:val, ":t:r")')
endif

:com -nargs=1 -complete=customlist,<SID>FileTypeComplete Filetype :set
ft=<args>

fu! <SID>FileTypeComplete(ArgLead,CmdLine,CursorPos)
    let l=filter(copy(s:ftlist), 'v:val =~ "^".a:ArgLead')
    return sort(l)
endfu

> If Vim is not able to determine the correct file type automatically,
> the proper solution is to give it better guidance in the user's
> ~/.vim/filetype.vim, not require the user to set the file type
> manually every time he opens such a file.

true.

regards,
Christian


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

Raspunde prin e-mail lui