0

Consider i want to make something like this

row one goes like this
row two goes like this
woops like this
woops like what happend now

and i want the like to be aligned in all sentences, something like this:

row one goes like this
row two goes like this
woops        like this
woops        like what happend now

Now imagine i want to do this for 100+ lines, is there a way to indent my lines effective without having to go through every line?

I have tried M-i, which is perfect for 1 row, but i can't figure out the vertical aligning part,

  • 1
    Try M-x align-regexp. Mark region, input M-x align-regexp, press RETURN, and input like as alignment regexp. – Tobias Feb 21 at 17:16
  • @Tobias Works as a charm, add this as an answer and i will accept it. (Also if you could add an explanation how to change the length of the indent itself) – JohEker Feb 21 at 19:46
2

You can use M-x align-regexp RET like RET. Thereby like stands for the regexp identifying the part of the line that should be aligned.

Note that the variable align-to-tab-stop influences the alignment. If it is set to indent-tabs-mode tabs are inserted for alignment. Set it to nil if you want spaces instead.

There is also the "expert mode" of align-regexp where you can specify the regexp group that is expanded for alignment, the alignment size, and whether you want rather to justify the text instead of alignment.

The key sequence for the expert mode is C-u M-x align-regexp RET ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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