Loading ...
Sorry, an error occurred while loading the content.

Re: matchit doesn't work for html files without extension

Expand Messages
  • Cesar Romani
    ... Without the first line: works but not with it. If the file has the extension html, it works in all of cases. Thanks,
    Message 1 of 11 , May 29, 2009
    • 0 Attachment
      Matt Wozniski wrote:
      > On Fri, May 29, 2009 at 8:35 PM, Cesar Romani wrote:
      >> I'm using vim 7.2.184 on Windows XP.
      >> If I load a html file without extension, let's say "test"
      >>
      >> <?xml version="1.0" encoding="UTF-8"?>
      >> <html>
      >> <head>
      >> <title>Test</title>
      >> </head>
      >> <body>
      >> blah blah blah
      >> </body>
      >> </html>
      >>
      >> matchit doesn't work on it, notwithstanding the fact that I set
      >> set ft=html
      >
      > Works fine for me. Are you positive you didn't mistype something when
      > doing the :set ft=html ? If that's not it, maybe another autocmd is
      > getting in the way?
      >
      > ~Matt

      Without the first line: <?xml version="1.0" encoding="UTF-8"?>
      works but not with it.
      If the file has the extension html, it works in all of cases.

      Thanks,
      Cesar


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Gene Kwiecinski
      ... What s *probably* happening is that there s some check on the file contents itself, failing a .htm/.html extension, to determine whether/not the file s
      Message 2 of 11 , May 30, 2009
      • 0 Attachment
        >Without the first line: <?xml version="1.0" encoding="UTF-8"?>
        >works but not with it.
        >If the file has the extension html, it works in all of cases.

        What's *probably* happening is that there's some check on the file
        contents itself, failing a .htm/.html extension, to determine
        whether/not the file's actually html.

        xml is *not* html. html is a subset of sgml with the html #.# dtd (eg,
        html3.2, html4.0, etc.). If you want, you can specify *xhtml*. But an
        html file inside a xml "wrapper" is just wrong. Wouldn't surprise me if
        that was coded into the matchit plugin somehow. "File has a .htm/.html
        extension? Nope. Let's see what's inside... First line has '<html...>'
        anywhere? Nope. Okay, so it ain't html!"

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Cesar Romani
        ... You are right but if I set set ft=html or set ft=xhtml it should be forced to be an html file because with the extension .htm/.html, matchit works
        Message 3 of 11 , May 30, 2009
        • 0 Attachment
          Gene Kwiecinski wrote:
          >> Without the first line: <?xml version="1.0" encoding="UTF-8"?>
          >> works but not with it.
          >> If the file has the extension html, it works in all of cases.
          >
          > What's *probably* happening is that there's some check on the file
          > contents itself, failing a .htm/.html extension, to determine
          > whether/not the file's actually html.
          >
          > xml is *not* html. html is a subset of sgml with the html #.# dtd (eg,
          > html3.2, html4.0, etc.). If you want, you can specify *xhtml*. But an
          > html file inside a xml "wrapper" is just wrong. Wouldn't surprise me if
          > that was coded into the matchit plugin somehow. "File has a .htm/.html
          > extension? Nope. Let's see what's inside... First line has '<html...>'
          > anywhere? Nope. Okay, so it ain't html!"

          You are right but if I set "set ft=html" or "set ft=xhtml" it should be
          forced to be an html file because with the extension .htm/.html, matchit
          works fine.

          Thanks,
          Cesar


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Matt Wozniski
          ... That s not what s happening; it works for me after doing :set ft=html. ... So something else must be interfering with you. If you could reproduce it from
          Message 4 of 11 , May 30, 2009
          • 0 Attachment
            On Sat, May 30, 2009 at 11:14 AM, Cesar Romani wrote:
            >
            > Gene Kwiecinski wrote:
            >>> Without the first line: <?xml version="1.0" encoding="UTF-8"?>
            >>> works but not with it.
            >>> If the file has the extension html, it works in all of cases.
            >>
            >> What's *probably* happening is that there's some check on the file
            >> contents itself, failing a .htm/.html extension, to determine
            >> whether/not the file's actually html.

            That's not what's happening; it works for me after doing :set ft=html.

            >> xml is *not* html.  html is a subset of sgml with the html #.# dtd (eg,
            >> html3.2, html4.0, etc.).  If you want, you can specify *xhtml*.  But an
            >> html file inside a xml "wrapper" is just wrong.  Wouldn't surprise me if
            >> that was coded into the matchit plugin somehow.  "File has a .htm/.html
            >> extension? Nope. Let's see what's inside... First line has '<html...>'
            >> anywhere? Nope. Okay, so it ain't html!"
            >
            > You are right but if I set "set ft=html" or "set ft=xhtml" it should be
            > forced to be an html file because with the extension .htm/.html, matchit
            > works fine.

            So something else must be interfering with you. If you could
            reproduce it from "vim -u NONE -N" after only sourcing matchit.vim,
            I'd be truly surprised.

            ~Matt

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Cesar Romani
            ... If I do vim -u NONE -N test and source matchit.vim, it doesn t work at all, not even with a extension .html Thanks, Cesar
            Message 5 of 11 , May 30, 2009
            • 0 Attachment
              Matt Wozniski wrote:
              > On Sat, May 30, 2009 at 11:14 AM, Cesar Romani wrote:
              >> Gene Kwiecinski wrote:
              >>>> Without the first line: <?xml version="1.0" encoding="UTF-8"?>
              >>>> works but not with it.
              >>>> If the file has the extension html, it works in all of cases.
              >>> What's *probably* happening is that there's some check on the file
              >>> contents itself, failing a .htm/.html extension, to determine
              >>> whether/not the file's actually html.
              >
              > That's not what's happening; it works for me after doing :set ft=html.
              >
              >>> xml is *not* html. html is a subset of sgml with the html #.# dtd (eg,
              >>> html3.2, html4.0, etc.). If you want, you can specify *xhtml*. But an
              >>> html file inside a xml "wrapper" is just wrong. Wouldn't surprise me if
              >>> that was coded into the matchit plugin somehow. "File has a .htm/.html
              >>> extension? Nope. Let's see what's inside... First line has '<html...>'
              >>> anywhere? Nope. Okay, so it ain't html!"
              >> You are right but if I set "set ft=html" or "set ft=xhtml" it should be
              >> forced to be an html file because with the extension .htm/.html, matchit
              >> works fine.
              >
              > So something else must be interfering with you. If you could
              > reproduce it from "vim -u NONE -N" after only sourcing matchit.vim,
              > I'd be truly surprised.
              >
              > ~Matt

              If I do "vim -u NONE -N test" and source matchit.vim, it doesn't work at
              all, not even with a extension .html
              Thanks,
              Cesar


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Matt Wozniski
              ... Fair enough, I was forgetting that the html ftplugin would need to be loaded, too. It should work after doing this command line (broken into multiple
              Message 6 of 11 , May 30, 2009
              • 0 Attachment
                Cesar Romani wrote:
                > Matt Wozniski wrote:
                >> Cesar Romani wrote:
                >>> Gene Kwiecinski wrote:
                >>>>> Without the first line: <?xml version="1.0" encoding="UTF-8"?>
                >>>>> works but not with it.
                >>>>> If the file has the extension html, it works in all of cases.
                >>>> What's *probably* happening is that there's some check on the file
                >>>> contents itself, failing a .htm/.html extension, to determine
                >>>> whether/not the file's actually html.
                >>
                >> That's not what's happening; it works for me after doing :set ft=html.
                >>
                >>>> xml is *not* html.  html is a subset of sgml with the html #.# dtd (eg,
                >>>> html3.2, html4.0, etc.).  If you want, you can specify *xhtml*.  But an
                >>>> html file inside a xml "wrapper" is just wrong.  Wouldn't surprise me if
                >>>> that was coded into the matchit plugin somehow.  "File has a .htm/.html
                >>>> extension? Nope. Let's see what's inside... First line has '<html...>'
                >>>> anywhere? Nope. Okay, so it ain't html!"
                >>> You are right but if I set "set ft=html" or "set ft=xhtml" it should be
                >>> forced to be an html file because with the extension .htm/.html, matchit
                >>> works fine.
                >>
                >> So something else must be interfering with you.  If you could
                >> reproduce it from "vim -u NONE -N" after only sourcing matchit.vim,
                >> I'd be truly surprised.
                >
                > If I do "vim -u NONE -N test" and source matchit.vim, it doesn't work at
                > all, not even with a extension .html

                Fair enough, I was forgetting that the html ftplugin would need to be
                loaded, too. It should work after doing this command line (broken
                into multiple lines for readability, and to prevent wrapping):

                vim -u NONE -N testfile \
                -c 'runtime macros/matchit.vim' \
                -c 'filetype plugin on' \
                -c 'set ft=html'

                This time I actually tested, and it works for me. ;-)

                ~Matt

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Gene Kwiecinski
                ... matchit ... But that s done *after* the file s read into the buffer, and it may do that check only once at that time, and not after. Basically, you might
                Message 7 of 11 , May 31, 2009
                • 0 Attachment
                  >>What's *probably* happening is that there's some check on the file
                  >>contents itself, failing a .htm/.html extension, to determine
                  >>whether/not the file's actually html.

                  >You are right but if I set "set ft=html" or "set ft=xhtml" it should be
                  >forced to be an html file because with the extension .htm/.html,
                  matchit
                  >works fine.

                  But that's done *after* the file's read into the buffer, and it may do
                  that check only once at that time, and not after. Basically, you might
                  be hoping to still catch your flight at the airport even after the
                  plane's already taken off.

                  Dunno, I haven't dissected 'matchit' to know what it actually does, so
                  this is still only a guess.

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Cesar Romani
                  ... (eg, ... But an ... me if ... .htm/.html ... matchit ... Thanks a lot, it is working now. The culprit was a ftplugin in my vimfiles folder: xml.vim, dated
                  Message 8 of 11 , May 31, 2009
                  • 0 Attachment
                    Matt Wozniski wrote:
                    > Cesar Romani wrote:
                    >> Matt Wozniski wrote:
                    >>> Cesar Romani wrote:
                    >>>> Gene Kwiecinski wrote:
                    >>>>>> Without the first line: <?xml version="1.0" encoding="UTF-8"?>
                    >>>>>> works but not with it.
                    >>>>>> If the file has the extension html, it works in all of cases.
                    >>>>> What's *probably* happening is that there's some check on the file
                    >>>>> contents itself, failing a .htm/.html extension, to determine
                    >>>>> whether/not the file's actually html.
                    >>> That's not what's happening; it works for me after doing :set ft=html.
                    >>>
                    >>>>> xml is *not* html. html is a subset of sgml with the html #.# dtd
                    (eg,
                    >>>>> html3.2, html4.0, etc.). If you want, you can specify *xhtml*.
                    But an
                    >>>>> html file inside a xml "wrapper" is just wrong. Wouldn't surprise
                    me if
                    >>>>> that was coded into the matchit plugin somehow. "File has a
                    .htm/.html
                    >>>>> extension? Nope. Let's see what's inside... First line has '<html...>'
                    >>>>> anywhere? Nope. Okay, so it ain't html!"
                    >>>> You are right but if I set "set ft=html" or "set ft=xhtml" it should be
                    >>>> forced to be an html file because with the extension .htm/.html,
                    matchit
                    >>>> works fine.
                    >>> So something else must be interfering with you. If you could
                    >>> reproduce it from "vim -u NONE -N" after only sourcing matchit.vim,
                    >>> I'd be truly surprised.
                    >> If I do "vim -u NONE -N test" and source matchit.vim, it doesn't work at
                    >> all, not even with a extension .html
                    >
                    > Fair enough, I was forgetting that the html ftplugin would need to be
                    > loaded, too. It should work after doing this command line (broken
                    > into multiple lines for readability, and to prevent wrapping):
                    >
                    > vim -u NONE -N testfile \
                    > -c 'runtime macros/matchit.vim' \
                    > -c 'filetype plugin on' \
                    > -c 'set ft=html'
                    >
                    > This time I actually tested, and it works for me. ;-)
                    >
                    > ~Matt

                    Thanks a lot, it is working now. The culprit was a ftplugin in my
                    vimfiles folder: xml.vim, dated from 2005/10/03
                    I deleted it and I'm using the xml.vim which comes with vim.

                    Regards,
                    Cesar


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Tony Mechelynck
                    ... Now that you ve got your answer, let me chime in: the above file is plainly _wrong_ as HTML. It could be XHTML, but in that case it would need an XHTML
                    Message 9 of 11 , Jun 3, 2009
                    • 0 Attachment
                      On 30/05/09 02:35, Cesar Romani wrote:
                      >
                      > I'm using vim 7.2.184 on Windows XP.
                      > If I load a html file without extension, let's say "test"
                      >
                      > <?xml version="1.0" encoding="UTF-8"?>
                      > <html>
                      > <head>
                      > <title>Test</title>
                      > </head>
                      > <body>
                      > blah blah blah
                      > </body>
                      > </html>
                      >
                      > matchit doesn't work on it, notwithstanding the fact that I set
                      > set ft=html
                      >
                      > If I rename the file to "test.html", it works fine.
                      > How can I enable matchit on "test"?
                      >
                      > Many thanks in advance,
                      > Cesar

                      Now that you've got your answer, let me chime in: the above file is
                      plainly _wrong_ as HTML.

                      It could be XHTML, but in that case it would need an XHTML doctype line
                      immediately after the <?xml header, and I don't know what such a doctype
                      should be. However, XHTML syntax is much stricter than HTML syntax, and
                      in particular:
                      - There are no optionally-closed tags: all optionally-closed tags become
                      mandatorily-closed (such as <p>blah blah</p>, <li>blah blah</li> etc.
                      - Never-closed tags become self-closed (e.g. <hr />, <br />; see also
                      the <meta> tag below)
                      - All tag names and attribute names are lowercase
                      - All attribute values must be quoted (e.g. <div align="center">, not
                      <div align=center>
                      - Unlike in XML and general SGML, a paired tag which happens to be empty
                      must still be paired and not self-closed, e.g. <a name="some_stuff"
                      id="some_stuff"></a>, NOT a single <a with /> at the end and no </a>.

                      OR it could be HTML, but an HTML file MUST NOT include an <?xml line; it
                      SHOULD start with an HTML doctype; the following works well for me, but
                      there are other possibilities (I put it linewise in Vim's register "d (D
                      for Doctype is easy to remember), and the |viminfo| file remembers it
                      for me):

                      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                      For an HTML file, if you aren't master of the HTTP headers which tell
                      the browser the MIME type, there are still two ways (not exclusive of
                      each other) to say that it is encoded in UTF-8, without using an <?xml
                      header which is forbidden with this kind of file:

                      (a) use a UTF-8 BOM by using ":setlocal bomb fenc=utf-8" in Vim. Every
                      browser should accept that and, as a minimum, look past the BOM for the
                      doctype line.
                      (b) Include in the <head> part the following line:

                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

                      The above line is written in "XHTML style" but "HTML browsers" ought to
                      accept it too, even in a "purely" HTML file. Or you could use the
                      following (which is now deprecated), but not in an XHTML page:

                      <META HTTP-EQUIV=Content-Type CONTENT="text/html; charset=utf-8">

                      Notice that the CONTENT attribute value MUST still be quoted because it
                      includes a space.


                      Best regards,
                      Tony.
                      --
                      I think pop music has done more for oral intercourse than anything else
                      that has ever happened, and vice versa.
                      -- Frank Zappa

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    Your message has been successfully submitted and would be delivered to recipients shortly.