With emacs, how to go to the pairing (balancing) parentheses

前端 未结 6 1128
感情败类
感情败类 2021-01-30 08:29

When cursor on one parentheses, how to jump to the pairing parentheses. Good to work in emacs -nw .

Just like % in Vim.

;;Afte

6条回答
  •  梦毁少年i
    2021-01-30 09:04

    I use the following small function for exactly that (though I don't know whether or not it matches vim's behavior; I'm no vim user myself):

    (defun mo-match-paren (arg)
      "Go to the matching parenthesis."
      (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)))))
    

提交回复
热议问题