3

We have a custom filetype at work which I use with a plugin i've written. There we have a construct like this:

\item some text.
  it is indented on level more than the \item tag
\item the next item should be indentend the same as the previous one

If i type this, I end with that:

\item abc
  \item abc

Because the indent is increased for the text. Now if I do a == on that line, it is aligned correctly which tells me, that my indent file works correctly. But I want to do this automatically. Since the \item tag is used a lot, it is laborious to do it manually all the time.

So my question, what is resposible for the automatic indent, how can my plugin fix that. I now that it won't be possible to give me an working solutions with the information I provide, but it should be sufficient to point me to the right direction.

Thanks

P.S. I know it looks like LateX, but due to other things used in the fileformat, I can't just use a LateX plugin. (And my Plugin has some other useful stuff).

3

You can use the indentkeys option, e.g. something like this:

setlocal indentkeys+==item

For LaTeX files, I use this (in vimtex):

setlocal indentkeys+=[,(,{,),},],\&,=item

See :h indentkeys for more info on the syntax.

  • And it was this easy... Thank you very much. Unfortunaly I wasn't able to find that information anywhere. However, that was maybe my fault. – Doktor OSwaldo Oct 2 '17 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.