As per indentation section of the Style guide for Sphinx-based documentations:

Indent with 2 spaces.


toctree directive requires a 3 spaces indentation.

So how to set Vim to auto-indent the rst file while typing, so that it indents with 2 spaces while with 3 spaces for toctree directives?

  • 1
    I dont know what level of indent support exists for RST, but you could potentially wrap it up in a custom indentexpr function that calculates the appropriate indent based on that directive and defaults to the original otherwise.
    – D. Ben Knoble
    May 26 at 1:19
  • @D.BenKnoble Thanks for the direction, then that would be where I look into.
    – Gordon Bai
    May 26 at 1:46

Your Answer

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

Browse other questions tagged or ask your own question.