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

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

Expand Messages
  • 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 1 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.