I was using paredit for other languages apart from lisp and it was great for being able to delete and yank whole functions etc. but it was also quite buggy with web-mode and js2-mode.

Fir example, I could hit ctrl + K at the first line of the code below:

const  = (x) => {
  // function body

and it would cut the entire function. This worked with html in web-mode etc.

Is there anyway I can replicate this behaviour without paredit or how do more seasoned emacs users go about copying whole expressions like this or working with them in non-lisp languages?

  • Have you tried kill-sexp, which is bound to C-M-k? It kills the next sexp. There is also backward-kill-sexp, bound to C-M-<backspace>, which kills the previous sexp. – Drew Apr 9 '17 at 15:21
  • I guess that doesn't work, because all of that text is not one sexp. So try C-M-h to select it all, then C-w to kill it. (Presumably it is a defun.) That doesn't seem to include the ; at the end, however. – Drew Apr 9 '17 at 15:25
  • C-M- means press and hold Control plus Alt keys (C- is Control, M- is Meta, which is usually Alt). (However, for C-M-<backspace> you might need to use ESC C-<backspace>. You can use ESC as a prefix key instead of Alt as a modifier key.) – Drew Apr 9 '17 at 15:27
  • What about using paragraphs for it? You can mark an entire paragraph with M-h and then kill it or do something else with it. – user12563 Apr 9 '17 at 15:28

Your Answer

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

Browse other questions tagged or ask your own question.