With Vim's plugin matchit, you can match not only parens, but also a lot more language structures that come in paris (e.g. , if..end, do..end).

Now I'm using Emacs (for fun!), and I wonder if there is something similar to this plugin?

Thanks very much.

link|improve this question
feedback

2 Answers

I dont know which plugin matches the language structures, but I do use a simple function which matches simply parenthesis.

Okay I haven't written this function, copied from somewhere

;; goto-matching-paren
;; -------------------
;; If point is sitting on a parenthetic character, jump to its match.
;; This matches the standard parenthesis highlighting for determining which
;; one it is sitting on.
;;
(defun goto-matching-paren ()
  "If point is sitting on a parenthetic character, jump to its match."
  (interactive)
  (cond ((looking-at "\\s\(") (forward-list 1))
        ((progn
           (backward-char 1)
           (looking-at "\\s\)")) (forward-char 1) (backward-list 1))))
(define-key global-map [(control ?c) ?p] 'goto-matching-paren) ; Bind to C-c p
link|improve this answer
I'm using the evil-mode, which gives this simple paren-matching for free (bind to % as vim does). But what I need is something more extensive. Thanks anyway. – E.T Nov 6 '11 at 18:13
feedback

I don't think there is a general facility since it depends heavily on the language being edited. For example GAP mode which I have worked on, does have a function emulating vim's % key, but I'm pretty sure that, for example, cc-mode doesn't. Ruby mode is an example of a mode that has functions for going forward and backward across logical blocks like class ... end but I don't think it has a match. It's not very emacsy to have a match, rather a forward and backward is more typical since it's more powerful.

What mode(s) are you interested in?

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.