Skip to content

Instantly share code, notes, and snippets.

@ninjudd
Created August 10, 2012 20:38
Show Gist options
  • Save ninjudd/3317672 to your computer and use it in GitHub Desktop.
Save ninjudd/3317672 to your computer and use it in GitHub Desktop.
(defun compress-space-forward ()
"*Replaces all spaces, tabs and newlines after point with a single space."
(interactive)
(re-search-forward "[ \t\n\r]+\\([^ \t\n\r]\\)" nil t)
(replace-match " \\1" nil nil))
(defun compress-space-backward ()
"*Replaces all spaces, tabs and newlines after point with a single space."
(interactive)
(re-search-backward "\\([^ \t\n\r]\\)[ \t\n\r]+" nil t)
(replace-match "\\1 " nil nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment