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

How to modify tex.vim for the correct indentation of commands from latex algorithmicx package

Expand Messages
  • Peng Yu
    Hi, I want to indent the following latex. Can anybody show me how to modify tex.vim? The latex algorithmicx package is at
    Message 1 of 6 , Oct 31, 2007
    • 0 Attachment
      Hi,

      I want to indent the following latex. Can anybody show me how to
      modify tex.vim?

      The latex algorithmicx package is at http://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/

      Thanks,
      Peng

      \State something
      \Repeat
      \State something
      \If{something}
      something
      \EndIf
      \Until something \Comment{something}


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Charles E Campbell Jr
      ... I assume you want to modify indent/tex.vim (and that you have : filetype indent on in your .vimrc). Don t modify the system version. Instead, under your
      Message 2 of 6 , Nov 1, 2007
      • 0 Attachment
        Peng Yu wrote:

        >I want to indent the following latex. Can anybody show me how to
        >modify tex.vim?
        >
        >The latex algorithmicx package is at http://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
        >
        >Thanks,
        >Peng
        >
        > \State something
        > \Repeat
        > \State something
        > \If{something}
        > something
        > \EndIf
        > \Until something \Comment{something}
        >
        >
        I assume you want to modify indent/tex.vim (and that you have :
        filetype indent on in your .vimrc). Don't modify the system version.
        Instead, under your .vim/ directory (vimfiles\ under Windoze), make a
        indent/tex.vim file and edit that. Read :help 30.4 .

        Regards,
        Chip Campbell


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Peng Yu
        On Nov 1, 3:13 pm, Charles E Campbell Jr ... Hi, I knew I should modify my local indent/tex.vim. I just read :help 30.4. I do not
        Message 3 of 6 , Nov 1, 2007
        • 0 Attachment
          On Nov 1, 3:13 pm, Charles E Campbell Jr <drc...@...>
          wrote:
          > Peng Yu wrote:
          > >I want to indent the following latex. Can anybody show me how to
          > >modify tex.vim?
          >
          > >The latex algorithmicx package is athttp://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
          >
          > >Thanks,
          > >Peng
          >
          > > \State something
          > > \Repeat
          > > \State something
          > > \If{something}
          > > something
          > > \EndIf
          > > \Until something \Comment{something}
          >
          > I assume you want to modify indent/tex.vim (and that you have :
          > filetype indent on in your .vimrc). Don't modify the system version.
          > Instead, under your .vim/ directory (vimfiles\ under Windoze), make a
          > indent/tex.vim file and edit that. Read :help 30.4 .

          Hi,

          I knew I should modify my local indent/tex.vim. I just read :help
          30.4. I do not see how to extend the current indent/tex.vim easily to
          support the constructs from algorithmicx, such as \If, \EndIf. Do you
          have any idea how to modify it?

          Thanks,
          Peng


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • A.Politz
          ... Write youw own indent function, which handles this special cases and wrap it around the indent/tex.vim function, e.g.: fun MyTexIndent(lnum) let indent =
          Message 4 of 6 , Nov 2, 2007
          • 0 Attachment
            Peng Yu wrote:

            >
            >On Nov 1, 3:13 pm, Charles E Campbell Jr <drc...@...>
            >wrote:
            >
            >
            >>Peng Yu wrote:
            >>
            >>
            >>>I want to indent the following latex. Can anybody show me how to
            >>>modify tex.vim?
            >>>
            >>>
            >>>The latex algorithmicx package is athttp://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
            >>>
            >>>
            >>>Thanks,
            >>>Peng
            >>>
            >>>
            >>> \State something
            >>> \Repeat
            >>> \State something
            >>> \If{something}
            >>> something
            >>> \EndIf
            >>> \Until something \Comment{something}
            >>>
            >>>
            >>I assume you want to modify indent/tex.vim (and that you have :
            >>filetype indent on in your .vimrc). Don't modify the system version.
            >>Instead, under your .vim/ directory (vimfiles\ under Windoze), make a
            >>indent/tex.vim file and edit that. Read :help 30.4 .
            >>
            >>
            >
            >Hi,
            >
            >I knew I should modify my local indent/tex.vim. I just read :help
            >30.4. I do not see how to extend the current indent/tex.vim easily to
            >support the constructs from algorithmicx, such as \If, \EndIf. Do you
            >have any idea how to modify it?
            >
            >Thanks,
            >Peng
            >
            >
            >>
            >
            >
            Write youw own indent function, which handles this special
            cases and wrap it around the indent/tex.vim function, e.g.:

            fun MyTexIndent(lnum)
            let indent = indent(prevnonblank(a:lnum-1))
            if getline(prevnonblank(a:lnum-1))=~'^\s*\\If{'
            let indent += &sw
            elseif ....
            else
            return TexIndent(a:lnum)
            endif
            endfun


            -ap

            --
            Ich hab geträumt, der Krieg wär vorbei.


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Peng Yu
            ... What does a in a:lnum mean? Thanks, Peng --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist.
            Message 5 of 6 , Nov 2, 2007
            • 0 Attachment
              On Nov 2, 4:00 am, "A.Politz" <poli...@...> wrote:
              > Peng Yu wrote:
              >
              > >On Nov 1, 3:13 pm, Charles E Campbell Jr <drc...@...>
              > >wrote:
              >
              > >>Peng Yu wrote:
              >
              > >>>I want to indent the following latex. Can anybody show me how to
              > >>>modify tex.vim?
              >
              > >>>The latex algorithmicx package is athttp://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
              >
              > >>>Thanks,
              > >>>Peng
              >
              > >>> \State something
              > >>> \Repeat
              > >>> \State something
              > >>> \If{something}
              > >>> something
              > >>> \EndIf
              > >>> \Until something \Comment{something}
              >
              > >>I assume you want to modify indent/tex.vim (and that you have :
              > >>filetype indent on in your .vimrc). Don't modify the system version.
              > >>Instead, under your .vim/ directory (vimfiles\ under Windoze), make a
              > >>indent/tex.vim file and edit that. Read :help 30.4 .
              >
              > >Hi,
              >
              > >I knew I should modify my local indent/tex.vim. I just read :help
              > >30.4. I do not see how to extend the current indent/tex.vim easily to
              > >support the constructs from algorithmicx, such as \If, \EndIf. Do you
              > >have any idea how to modify it?
              >
              > >Thanks,
              > >Peng
              >
              > Write youw own indent function, which handles this special
              > cases and wrap it around the indent/tex.vim function, e.g.:
              >
              > fun MyTexIndent(lnum)
              > let indent = indent(prevnonblank(a:lnum-1))
              > if getline(prevnonblank(a:lnum-1))=~'^\s*\\If{'
              > let indent += &sw
              > elseif ....
              > else
              > return TexIndent(a:lnum)
              > endif
              > endfun

              What does "a" in "a:lnum" mean?

              Thanks,
              Peng


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • A.Politz
              ... To be honest, it will not be easy for you to do this if you don t know that. In vim, function arguments must have the a: prefix when they are referred
              Message 6 of 6 , Nov 2, 2007
              • 0 Attachment
                Peng Yu wrote:

                >
                >On Nov 2, 4:00 am, "A.Politz" <poli...@...> wrote:
                >
                >
                >>Peng Yu wrote:
                >>
                >>
                >>
                >>>On Nov 1, 3:13 pm, Charles E Campbell Jr <drc...@...>
                >>>wrote:
                >>>
                >>>
                >>>>Peng Yu wrote:
                >>>>
                >>>>
                >>>>>I want to indent the following latex. Can anybody show me how to
                >>>>>modify tex.vim?
                >>>>>
                >>>>>
                >>>>>The latex algorithmicx package is athttp://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
                >>>>>
                >>>>>
                >>>>>Thanks,
                >>>>>Peng
                >>>>>
                >>>>>
                >>>>>\State something
                >>>>>\Repeat
                >>>>> \State something
                >>>>> \If{something}
                >>>>> something
                >>>>> \EndIf
                >>>>>\Until something \Comment{something}
                >>>>>
                >>>>>
                >>>>I assume you want to modify indent/tex.vim (and that you have :
                >>>>filetype indent on in your .vimrc). Don't modify the system version.
                >>>>Instead, under your .vim/ directory (vimfiles\ under Windoze), make a
                >>>>indent/tex.vim file and edit that. Read :help 30.4 .
                >>>>
                >>>>
                >>>Hi,
                >>>
                >>>
                >>>I knew I should modify my local indent/tex.vim. I just read :help
                >>>30.4. I do not see how to extend the current indent/tex.vim easily to
                >>>support the constructs from algorithmicx, such as \If, \EndIf. Do you
                >>>have any idea how to modify it?
                >>>
                >>>
                >>>Thanks,
                >>>Peng
                >>>
                >>>
                >>Write youw own indent function, which handles this special
                >>cases and wrap it around the indent/tex.vim function, e.g.:
                >>
                >>fun MyTexIndent(lnum)
                >> let indent = indent(prevnonblank(a:lnum-1))
                >> if getline(prevnonblank(a:lnum-1))=~'^\s*\\If{'
                >> let indent += &sw
                >> elseif ....
                >> else
                >> return TexIndent(a:lnum)
                >> endif
                >>endfun
                >>
                >>
                >
                >What does "a" in "a:lnum" mean?
                >
                >Thanks,
                >Peng
                >
                >
                >>
                >
                >
                To be honest, it will not be easy for you to do this
                if you don't know that.
                In vim, function arguments must have the 'a:' prefix
                when they are referred to.

                fun Foo( arg )
                "local arg, implicit l:arg
                let arg = 1
                " the functions argument :
                let foo = a:arg
                endfun

                Read ':h eval.txt' for the whole story.

                -ap

                --
                Ich hab geträumt, der Krieg wär vorbei.


                --~--~---------~--~----~------------~-------~--~----~
                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.