Emacs bulk indent for Python

前端 未结 8 1240
星月不相逢
星月不相逢 2021-01-29 17:37

Working with Python in Emacs if I want to add a try/except to a block of code, I often find that I am having to indent the whole block, line by line. In Emacs, how do you inden

相关标签:
8条回答
  • 2021-01-29 18:29

    Do indentation interactively.

    1. Select the region to be indented.
    2. C-x TAB.
    3. Use arrows (<- and ->) to indent interactively.
    4. Press Esc three times when you are done with the required indentation.

    Copied from my post in: Indent several lines in Emacs

    0 讨论(0)
  • 2021-01-29 18:29

    I do something like this universally

    ;; intent whole buffer 
    (defun iwb ()
      "indent whole buffer"
      (interactive)
      ;;(delete-trailing-whitespace)
      (indent-region (point-min) (point-max) nil)
      (untabify (point-min) (point-max)))
    
    0 讨论(0)
提交回复
热议问题