Skip to content

Instantly share code, notes, and snippets.

@snim2
Created December 12, 2009 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snim2/255084 to your computer and use it in GitHub Desktop.
Save snim2/255084 to your computer and use it in GitHub Desktop.
Convert spaces to tabs in Emacs
(defun four-spaces-to-tab (&optional begin end)
"Replace four spaces with a tab in a region."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp " " "\t" nil (point) (mark))
(replace-regexp " " "\t" nil (point-min) (point-max))
)
)
)
(defun eight-spaces-to-tab (&optional begin end)
"Replace eight spaces with a tab in a region."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp " " "\t" nil (point) (mark))
(replace-regexp " " "\t" nil (point-min) (point-max))
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment