Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created November 9, 2011 23:37
Show Gist options
  • Save tizoc/1353555 to your computer and use it in GitHub Desktop.
Save tizoc/1353555 to your computer and use it in GitHub Desktop.
(defun smart-tab ()
"If mark is active, indents region. Else if point is at the end of a symbol,
expands it. Else indents the current line. Acts as normal in minibuffer."
(interactive)
(cond (mark-active (indent-region (region-beginning) (region-end)))
((and (looking-at "\\_>") (not (looking-back "end\\|\\}")))
(hippie-expand nil))
(t (indent-for-tab-command))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment