Skip to content

Instantly share code, notes, and snippets.

@LouisKottmann
Created December 6, 2013 10:35
Show Gist options
  • Save LouisKottmann/7821725 to your computer and use it in GitHub Desktop.
Save LouisKottmann/7821725 to your computer and use it in GitHub Desktop.
(defun align-regexp-lefty ()
"After using align-regexp, this will move spaces to the left."
(interactive)
(let (pos1 pos2)
(if (region-active-p)
((setq pos1 (region-beginning) pos2 (region-end))
(save-restriction
(narrow-to-region pos1 pos2)
(goto-char (point-min))
(while (re-search-forward "\(\w+\)\ \(\ *\)" nil t)
(replace-match "\2\1")))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment