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
In addition to indent-region
, which is mapped to C-M-\
by default, the rectangle edit commands are very useful for Python. Mark a region as normal, then:
C-x r t
(string-rectangle
): will prompt you for characters you'd like to insert into each line; great for inserting a certain number of spacesC-x r k
(kill-rectangle
): remove a rectangle region; great for removing indentationYou can also C-x r y
(yank-rectangle
), but that's only rarely useful.