90853Re: syntax auto detect
- May 23, 2008On 23/05/08 23:46, zhengquan wrote:
> Hello,It all depends on the syntax, I think, and filetype.vim does quite a
> I saw the detection method in filetype.vim
> It peeks the first line to see what it is, I wonder if there are
> smarter and more automatic ways to detect the syntax and tell what the
> filetype is.
good job. For some types, like *.c, *.cpp, *.htm, *.html, *.vim, vimrc,
fstab, etc., the mere name of the file, or even part of it, is enough to
determine the filetype, and in those cases filetype.vim uses that. For
other filetypes, that's not enough: for example, Unix shell scripts can
have any name, so something else must be used to define them. Checking
them for "executable" permissions wouldn't work, since on Unix, binary
executables also have those permissions and can also have any name
(unlike on Windows, where *.bat and sometimes *.btm are shell scripts,
while *.exe and sometimes *.dll, *.com, etc., are binary executables).
Happily Unix shell scripts usually have #! followed by the shell name in
their first line, so that's a good criterion for that filetype.
We must remember the First Amendment which protects any shrill jackass
no matter how self-seeking.
-- F. G. Withington
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
- << Previous post in topic Next post in topic >>