Reputation: 11728
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
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