Hacker News new | ask | show | jobs
by tekacs 3123 days ago
Not that you should have to know this, but for completeness' sake:

Out of the box in Emacs (with no config or extensions) you can simply select the pasted region and hit Tab to reindent the whole area correctly (what you called 'Tab to the Right Indentation').

So in total:

* C-SPC (Mark)

* C-y (yank/paste)

* C-x C-x (select to mark, essentially)

* Tab (indent)

(https://xkcd.com/378/)

Does what you'd like. This is all compositional, no magic here (and of course you can bind this all to one key press). Naturally lots of people make this auto-indent by default.

For me the most essential thing to know about those auto-indent modes is how to temporarily turn them off (like `:set paste` in Vim), since I so often need to bypass that behaviour for one reason or another (e.g. when resolving Git merges - trying to keep the original formatting).