Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a set of rows like this:

This is a row.
This is row 2.
This is row 3.

I want to shift them over x number of spaces/tabs like this.

    This is a row.
    This is row 2.
    This is row 3.

Is there a way to select these rows and do some sort of M-x region-tab-n?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

`C-x TAB'

Shift each line in the region by a fixed distance, to the right or left (`indent-rigidly'). The distance to move is determined by the numeric argument (positive to move rightward, negative to move leftward).

share|improve this answer
    
You can prefix that with C-u x (where "x" is the number of spaces you want your lines shifted, not the letter x) as normal to repeat it. –  Inaimathi Jul 10 '12 at 13:34

If you know how many spaces you would like in front of each row: select the text as a region, then apply M-n C-M-\, where n is the number of spaces that you would like to indent. The M-n is a numeric argument to the command C-M-\. On its own, the command C-M-\ will bring all rows in the region to the left (zero spaces).

To shift right by n spaces: M-n C-x TAB

To shift left by n spaces: M-- M-n C-x TAB

share|improve this answer

Another way to do it is to put the mark (C-SPC) at the beginning of the first line, move point to the beginning of the last line, and hit C-x r t for string-rectangle. It will ask you for a string to insert on each line; you'd type in the desired number of spaces there.

(If point and mark are not at the same column, it will replace the text in the rectangle with corners in point and mark.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.