emacs - match parenthesis

One good thing I liked about vim is that the parenthesis matching is so damn easy - use %

So, in order to enable the same in emacs, add the following in your .emacs file
(global-set-key "%" 'match-paren)
    (defun match-paren (arg)
    "Go to the matching paren if on a paren; otherwise insert %."
    (interactive "p")
    (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
          ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
          (t (self-insert-command (or arg 1)))))


[source]

No comments: