How to indent a block of text rightward by 2 whitespace characters in Emacs?
How to indent a block of text rightward by 4 whitespace characters in Emacs?
[EDIT] I need a method that doesn't interfere with CUA mode.
Try the key binding C-x TAB (aka C-x C-i) which is bound to
So, you'd indent by two by pressing that twice setting the region around the code you want to indent and typing:
Or, you can pass a numeric prefix with
To get 4 spaces, do a prefix with 4
And, as a bonus, you can remove spaces with a negative prefix argument. Removing 4 spaces is accomplished by
|show 3 more comments|
You can also use Rectangles.
Mark the beginning of the region with C-Space, go to then end of the region and then type C-xrtRET.
I noticed your edit "I need a method that doesn't interfere with CUA mode." Assuming you have CUA mode enabled, I would also like to recommend you to try C-Enter (cua-set-rectangle-mark). Here is the sequence that works for me.