Skip to content

Instantly share code, notes, and snippets.

@darrik
Forked from anonymous/test.c
Created July 25, 2012 23:53
Show Gist options
  • Save darrik/3179417 to your computer and use it in GitHub Desktop.
Save darrik/3179417 to your computer and use it in GitHub Desktop.
Do want
(defadvice newline-and-indent (after darrik-nai-curly-special activate)
"Do something special when RET between {}."
(when (eq (char-after) ?\})
(let ((pos (point)))
(if (search-backward "{")
(progn
(goto-char pos)
(newline)
(indent-according-to-mode)
(previous-line)
(indent-according-to-mode))))))
/* | is cursor position */
if(blaha) {|} /* if I press enter while at | I want: */
if(blaha) { /* this */
|
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment