Jason Franklin wrote:

> YAML files are only detected when they end in ".yml" or ".yaml".
> 
> The change below allows for YAML to be detected by content:
> 
> diff --git a/runtime/scripts.vim b/runtime/scripts.vim
> index a69043101..71fc56a48 100644
> --- a/runtime/scripts.vim
> +++ b/runtime/scripts.vim
> @@ -376,6 +376,10 @@ else
>    elseif s:line1 =~? '-\*-.*erlang.*-\*-'
>      set ft=erlang
> 
> +  " YAML
> +  elseif s:line1 =~# '^\(---\|%YAML\)'
> +    set ft=yaml
> +
>    " CVS diff
>    else
>      let s:lnum = 1
> 
> If a file begins with "---" we can assume that this is a YAML document
> boundary symbol.  One may argue that this is not for sure, but it seems
> unlikely to me that any other type of content would begin this way.
> 
> The other possibility is when some text begins with a YAML version
> directive (e.g., "%YAML 1.2").  With this criteria we can be nearly
> certain of the type.
> 
> This doesn't handle all cases.  However, it will catch far more
> instances where the content of a file is YAML, yet the name doesn't
> match what is expected.

Recognizing "%YAML" should be fine.  However, it's not unusual for a
text file to start with something like:

-----------------------------
blah blah blah blah 
-----------------------------

I rather not see that as a yaml file.


-- 
hundred-and-one symptoms of being an internet addict:
181. You still remember the "happy tune" your modem made
     while dialing your ISP.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202003062131.026LViiJ001724%40masaka.moolenaar.net.

Raspunde prin e-mail lui