Useful keybindings for emacs python-mode

I wrote up this keybinding the other day at work, and found that I missed it when I went home, so I wrote it again from scratch.

It allows you easily indent or undent the current region using M-left and M-right:

(global-set-key [M-left] '(lambda () (interactive)
  (save-excursion
    (py-shift-region-left (region-beginning) (region-end)))))

(global-set-key [M-right] '(lambda () (interactive)
  (save-excursion
     (py-shift-region-right (region-beginning) (region-end)))))

Leave a Reply