tjb
tjb

Reputation: 11728

Emacs Function which eliminates all indentation

Is there an emacs function which eliminates all indentation in a region (i.e. all whitespace before the first non-whitespace character)?

If not, what snippet of code should I add to my .emacs to accomplish this?

Upvotes: 2

Views: 86

Answers (2)

Stefan
Stefan

Reputation: 28541

You can try C-u -1000 M-x indent-code-rigidly RET.

Upvotes: 3

phils
phils

Reputation: 73274

(defun my-delete-indentation (start end)
  "Delete all leading whitespace within the current region."
  (interactive "*r")
  (replace-regexp "^[[:space:]]+" "" nil start end))

(n.b. there is a delete-indentation function in Emacs, but it does something rather different to this.)

Upvotes: 4

Related Questions