0

I'm working on a .py document using a fresh apt install of emacs 25.2.2 on Ubuntu 18.04.

When typing TAB with several lines selected, the behavior is not what I remember getting previously, and not what I want. The current behavior seems mysterious. Example:

# a
if 1:
    # b
    if 2:
        # c
        print 3
    # d
    print 4

Selecting everything and typing TAB results in "# d" being indented, when I expected it to not change anything. So I thought maybe the default multi-line TAB behavior was equivalent to successive TAB on each line, but this is not the case either:

Changing "if 2:" to "print 2" and selecting the lines with "# c" and "print 3" then typing TAB only causes "# c" to unindent once, leaving "print 3" double-indented and now causing an indent error. I expected everything selected to unindent once.

-

How can I permanently change the behavior of TAB with multiple lines selected to what I expect? such that:

  • selections of code that were previously free of indent errors continue to be free of indent errors
  • comments that are aligned to the first line of code succeeding them are adjusted with that code

Based on reading, I believe I want TAB to enact a rigid auto-indent based on the first line highlighted. However, I'm not interested in typing multiple keys to achieve this, but only want to type TAB after highlighting.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.