Copyright (C) 2000-2012 |
GNU Info (efaq)Matching parenthesesHow do I show which parenthesis matches the one I'm looking at? =============================================================== As of version 19, Emacs comes with `paren.el', which (when loaded) will automatically highlight matching parentheses whenever point (i.e., the cursor) is located over one. To load `paren.el' automatically, include the line (require 'paren) in your `.emacs' file. Alan Shutko <shutkoa@ugsolutions.com> reports that as of version 20.1, you must also call `show-paren-mode' in your `.emacs' file: (show-paren-mode 1) Customize will let you turn on `show-paren-mode'. Use `M-x customize-group <RET> paren-showing <RET>'. From within Customize, you can also go directly to the "paren-showing" group. Alternatives to paren include: * If you're looking at a right parenthesis (or brace or bracket) you can delete it and reinsert it. Emacs will momentarily move the cursor to the matching parenthesis. * `M-C-f' (`forward-sexp') and `M-C-b' (`backward-sexp') will skip over one set of balanced parentheses, so you can see which parentheses match. (You can train it to skip over balanced brackets and braces at the same time by modifying the syntax table.) * Here is some Emacs Lisp that will make the <%> key show the matching parenthesis, like in `vi'. In addition, if the cursor isn't over a parenthesis, it simply inserts a % like normal. ;; By an unknown contributor (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))))) automatically generated by info2www version 1.2.2.9 |