【问题标题】:org-mode source editing indents code after exiting source code block editororg-mode 源代码编辑在退出源代码块编辑器后缩进代码
【发布时间】:2018-11-25 15:30:40
【问题描述】:

在组织模式下,对于给定的块:

#+BEGIN_SRC python
def hello():
    print('Hello world!')
#+END_SRC

I enter the source code editor with C-c ' 以及语法高亮和缩进以及其他一切都正常工作。

但是,在我用C-c ' 退出模式后,添加了2个缩进空格,因此源代码现在看起来像这样:

#+BEGIN_SRC python
  def hello():
      print('Hello world!')
#+END_SRC

如何修复它以便在编辑代码块后保留缩进?

【问题讨论】:

    标签: org-mode org-babel


    【解决方案1】:

    您可以通过设置以下变量在 org 模式下编辑代码块后保留缩进(感谢 Angelo Basile's article, "Org-mode Babel is cool" 的提示):

    (setq org-edit-src-content-indentation 0
          org-src-tab-acts-natively t
          org-src-preserve-indentation t)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 2018-08-23
      • 1970-01-01
      相关资源
      最近更新 更多