Indent Spaces in Emacs
Contents
We always need to indent spaces for code block or text block in Emacs, especially in Org files.
For example, when you inserts a code block in Emacs Org file, you always need to insert blocks similar to following:
#+begin_src cpp
#include
int main() { return 0; } #+end_src
But when you copy the code from your source code file, the code is always aligned to the left of the page. When you export your org file to html file, the # mark will damage all the code block content.
We need to indent the code block for 2 spaces or 4 spaces, then the block mark will work.
It’s easy! There are two ways to do the indention.
The first way, Use the indent-rigidly command with a numeric prefix.
For example, after selecting the block, 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.
You can also use C-x
The second way, we could also use column mode.
We can select the lines in column mode, then add four spaces to all of them at once by following steps:
- Jump to column 1 of the first line you want to indent.
- C-
to set mark. - move the point down to the last lines (stay in column one).
- C-x r t to enter column mode (or C-
if you’ve got CUA mode), the input to indent four spaces.
Author Watterry
LastMod 2012-11-13