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

Re: Filetype detect for *.tex

Expand Messages
  • Benji Fisher
    ... Charles Campbell maintains the (la)tex syntax file. When I asked him (a long time ago) about also supporting plain tex with the same file, he did not like
    Message 1 of 16 , Mar 1, 2006
    • 0 Attachment
      On Wed, Mar 01, 2006 at 11:17:43AM +0100, Bram Moolenaar wrote:
      >
      > Benji Fisher wrote:
      >
      > > I have been thinking about this. In vim 6.x, the default
      > > ftplugin/tex.vim tried to determine whether the file is latex or not.
      > > In vim 7, filetype.vim does pretty much the same. So we have some
      > > duplication here, which might make opening a .tex file a little slow;
      > > worse, it will be harder to maintain. (Maybe there are other flavors of
      > > TeX out there, gaining popularity.) I suggest two options:
      > >
      > > 1. Keep the vim 6.x way. Treat context as another flavor of tex. For
      > > ConTeXt files, set ft=tex and b:tex_flavor = context . Merge the syntax
      > > and ftplugin files for tex and context, with lots of "if b:tex_flavor ="
      > > switches.
      > >
      > > 2. Forget this "flavor" (or is it "flavour"?) business and have separate
      > > file types for plain TeX, LaTeX, and ConTeXt (and any others that come
      > > along). Remove the flavor-detection code from ftplugin/tex.vim . Two
      > > sub-options: use ft=tex for plain TeX and ft=latex for LaTeX (more
      > > logical) or ft=plaintex for plain TeX and ft=tex for LaTeX (more
      > > backwards compatible, since not many vim scripts have been written with
      > > plain TeX in mind).
      >
      > So far there was one tex syntax file for both TeX and LaTeX. Splitting
      > it up in separate syntax files has advantages and disadvantages. I
      > think the main issue is maintenance. If there are separate people
      > taking care of each flavor then it's probably simpler to split them up.
      > If there is one person doing multiple flavors, or more people working
      > closely together, then it's easier to use one file and avoid duplication
      > of the common parts.
      >
      > For a user it's easier to do ":set ft=latex" then it is to set
      > g:tex_flavor and then do ":set ft=tex". Thus that would mean splitting
      > up the filetypes. But the syntax files could still be shared by setting
      > g:tex_flavor and then loading a common syntax file.

      Charles Campbell maintains the (la)tex syntax file. When I asked
      him (a long time ago) about also supporting plain tex with the same
      file, he did not like the idea. Currently, plain tex is not well
      supported. This is not much of a problem, since most people use LaTeX
      (I think).

      Furthermore, we already have separate syntax and ftplugin files for
      ConTeXt.

      All of this argues (convincingly IMHO) for separate file types. I
      am leaning towards plaintex and tex instead of tex and latex. Again,
      few people use plain TeX and AFAIK there is not much in the way of vim
      scripts that cater to it, whereas a lot of people have tex plugins that
      would have to be made latex plugins if we decide on tex (for plain TeX)
      and latex. I will start a new thread to get more opinions on this
      point.

      I can maintain a ftplugin/plaintex.vim , and it may be useful if
      the (la)tex and context ftplugins :source it. I might even write (but
      not actively maintain) the syntax file, or maybe Nikolai Weibull can do
      that, if it is sufficiently close to the one for ConTeXt.

      I will make a new version of the FTtex() function, but not today.
      Is there any way to catch a match at the very start of the file with
      search(), analogous to

      :0/<pat>/

      HTH --Benji Fisher
    • Christian Ebert
      ... What I am missing are some customizations to support writing .dtx files. -- At least a search on vim.org didn t turn up any promising results (please
      Message 2 of 16 , Mar 1, 2006
      • 0 Attachment
        * Benji Fisher on Wednesday, March 01, 2006 at 10:54:00 -0500:
        > Charles Campbell maintains the (la)tex syntax file. When I asked
        > him (a long time ago) about also supporting plain tex with the same
        > file, he did not like the idea. Currently, plain tex is not well
        > supported. This is not much of a problem, since most people use LaTeX
        > (I think).

        What I am missing are some customizations to support writing .dtx
        files. -- At least a search on vim.org didn't turn up any
        promising results (please correct me if I'm wrong). This would be
        a huge relief for lazy package writers like me.

        c
        --
        _B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>
      • Gerald Lai
        On Wed, 1 Mar 2006, Benji Fisher wrote: [snip] ... To place the cursor at the beginning of the search occurence, remove ... The anchors for start and
        Message 3 of 16 , Mar 1, 2006
        • 0 Attachment
          On Wed, 1 Mar 2006, Benji Fisher wrote:
          [snip]
          > Is there any way to catch a match at the very start of the file with
          > search(), analogous to
          >
          > :0/<pat>/

          :0/<pat>/ places the cursor at the start of the line of the first
          occurence of <pat> from the beginning of the file. This is the same as:

          :call search('\%^\_.\{-}\zs.*<pat>')

          To place the cursor at the beginning of the search occurence, remove
          ".*":

          :call search('\%^\_.\{-}\zs<pat>')

          The anchors for start and end-of-file are \%^ and \%$, respectively :)
          --
          Gerald
        • Benji Fisher
          ... Thanks, that works. Still, I wonder whether this might be slower than :0/ . Maybe, before we get too used to the new stopline parameter to search()
          Message 4 of 16 , Mar 1, 2006
          • 0 Attachment
            On Wed, Mar 01, 2006 at 10:54:54AM -0800, Gerald Lai wrote:
            > On Wed, 1 Mar 2006, Benji Fisher wrote:
            > [snip]
            > >Is there any way to catch a match at the very start of the file with
            > >search(), analogous to
            > >
            > >:0/<pat>/
            >
            > :0/<pat>/ places the cursor at the start of the line of the first
            > occurence of <pat> from the beginning of the file. This is the same as:
            >
            > :call search('\%^\_.\{-}\zs.*<pat>')
            >
            > To place the cursor at the beginning of the search occurence, remove
            > ".*":
            >
            > :call search('\%^\_.\{-}\zs<pat>')
            >
            > The anchors for start and end-of-file are \%^ and \%$, respectively :)
            > --
            > Gerald

            Thanks, that works. Still, I wonder whether this might be slower
            than :0/<pat> . Maybe, before we get too used to the new stopline
            parameter to search() and related functions, we should ask Bram to add a
            startline parameter before it (both optional, of course).

            For example, suppose the cursor is on the first line and I want to
            search for something starting at Line 1000 without moving the cursor. I
            could use search('\%>999l<pat>'). If I understand how the search engine
            works (and I have never dived into the code, so maybe not) then this
            searches every character up to Line 1000, checking to see if it matches.
            It would be more readable, and faster if I am right, to use
            search('<pat>', '', 1000, 2000), where '' is the flags parameter, 1000
            is my suggested startline parameter, and 2000 is the new stopline
            parameter.

            --Benji Fisher
          • Bram Moolenaar
            ... You don t need a startline parameter, you can set the cursor to where you want the search to start. You just need to save and restore the cursor (I ll
            Message 5 of 16 , Mar 2, 2006
            • 0 Attachment
              Benji Fisher wrote:

              > On Wed, Mar 01, 2006 at 10:54:54AM -0800, Gerald Lai wrote:
              > > On Wed, 1 Mar 2006, Benji Fisher wrote:
              > > [snip]
              > > >Is there any way to catch a match at the very start of the file with
              > > >search(), analogous to
              > > >
              > > >:0/<pat>/
              > >
              > > :0/<pat>/ places the cursor at the start of the line of the first
              > > occurence of <pat> from the beginning of the file. This is the same as:
              > >
              > > :call search('\%^\_.\{-}\zs.*<pat>')
              > >
              > > To place the cursor at the beginning of the search occurence, remove
              > > ".*":
              > >
              > > :call search('\%^\_.\{-}\zs<pat>')
              > >
              > > The anchors for start and end-of-file are \%^ and \%$, respectively :)
              > > --
              > > Gerald
              >
              > Thanks, that works. Still, I wonder whether this might be slower
              > than :0/<pat> . Maybe, before we get too used to the new stopline
              > parameter to search() and related functions, we should ask Bram to add a
              > startline parameter before it (both optional, of course).
              >
              > For example, suppose the cursor is on the first line and I want to
              > search for something starting at Line 1000 without moving the cursor. I
              > could use search('\%>999l<pat>'). If I understand how the search engine
              > works (and I have never dived into the code, so maybe not) then this
              > searches every character up to Line 1000, checking to see if it matches.
              > It would be more readable, and faster if I am right, to use
              > search('<pat>', '', 1000, 2000), where '' is the flags parameter, 1000
              > is my suggested startline parameter, and 2000 is the new stopline
              > parameter.

              You don't need a startline parameter, you can set the cursor to where
              you want the search to start. You just need to save and restore the
              cursor (I'll make that a bit simpler).

              --
              How To Keep A Healthy Level Of Insanity:
              9. As often as possible, skip rather than walk.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ download, build and distribute -- http://www.A-A-P.org ///
              \\\ help me help AIDS victims -- http://www.ICCF.nl ///
            Your message has been successfully submitted and would be delivered to recipients shortly.