emacs: how to indent/unindent region of python code by 4 spaces?
Assuming that the variable python-indent
is 4:
M-x python-shift-right (C-c >)
M-x python-shift-left (C-c <)
indent-rigidly
takes a prefix argument indicating how much to indent by, so C-u 42 C-x TAB
indents by 42 columns, and since the default prefix argument is 4, C-u C-x TAB
indents by 4 columns.
If you want to select the region again, do C-x C-x
afterwards.
Use the indent-rigidly command with a numeric prefix.
C-u 4 M-x indent-rigidly
to indent the region by four spaces, C-u -4 M-x indent-rigidly
to remove four spaces.