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

前端 未结 6 1124
感情败类
感情败类 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条回答
  •  孤街浪徒
    2021-01-30 09:04

    I would highly recommend SmartParens it has extensive navigation and manipulation of parenthetical structures (ie. wrapping, quotes, tags, brackets, braces, regular parentheses, sexp, etc.) With support for many languages, and structures, with easy customization.

    It also supports fairly complex structures, which are referred to as hybrid-s-expressions in it's documentation. Which makes it extremely powerful for manipulating code in languages such as C/C++, Java, JS etc.

    For navigation the following are used.

    sp-forward-sexp (&optional arg)                 ;; C-M-f
    sp-backward-sexp (&optional arg)                ;; C-M-b
    sp-down-sexp (&optional arg)                    ;; C-M-d
    sp-backward-down-sexp (&optional arg)           ;; C-M-a
    sp-up-sexp (&optional arg)                      ;; C-M-e
    sp-backward-up-sexp (&optional arg)             ;; C-M-u
    sp-next-sexp (&optional arg)                    ;; C-M-n
    sp-previous-sexp (&optional arg)                ;; C-M-p
    sp-beginning-of-sexp (&optional arg)            ;; C-S-d
    sp-end-of-sexp (&optional arg)                  ;; C-S-a
    sp-beginning-of-next-sexp (&optional arg)       ;; none
    sp-beginning-of-previous-sexp (&optional arg)   ;; none
    sp-end-of-next-sexp (&optional arg)             ;; none
    sp-end-of-previous-sexp (&optional arg)         ;; none
    

    Note that it maps many to commands to the Emacs default equivalent. When it's installed, just browse it's functions (they're all prefixed with sp-) to get a good feeling for it's scale.

    There's a lot more to it, I'd recommend you have a look at the wiki

提交回复
热议问题