1

In normal mode in Vim, one can use y% to copy text between matching parenthesis. y starts the yanking command and % selects the matching closed or open parenthesis.

What is the Emacs equivalent of this operation?

migrated from stackoverflow.com Jan 3 at 13:44

This question came from our site for professional and enthusiast programmers.

4

You would mark the next sexp with C-M-SPC and copy the marked region to the kill-ring with M-w.

You might find such questions more appropriate on Emacs.SE.

0

M-x mark-defun (usually C-M-h, but in c-mode it's mapped to c-mark-function)

Jump between start and end of any region with C-x C-x to adjust boundaries of the selection.
Autocompleters like HELM show all functions that start with typed letters and their key bindings(if any).

Or:

C-M-u C-M-space

C-M-u backward-up-list, moves point to an opening paren or inner block.
C-M-space mark-sexp

Or:

C-M-a beginning-of-defun
C-M-e end-of-defun

...

C-space starts region selection. Move with any known key bindings. C-x C-x for adjustments.

  • Thank you for the comprehensive answer. I am just learning emacs. Only been a few days and your answer really helps with navigating and selecting stuff in lisp files. – Gordon Zar Jan 6 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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