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?
kill-sexp
, which is bound toC-M-k
? It kills the next sexp. There is alsobackward-kill-sexp
, bound toC-M-<backspace>
, which kills the previous sexp. – Drew Apr 9 '17 at 15:21C-M-h
to select it all, thenC-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:25C-M-
means press and hold Control plus Alt keys (C-
is Control,M-
is Meta, which is usually Alt). (However, forC-M-<backspace>
you might need to useESC C-<backspace>
. You can useESC
as a prefix key instead ofAlt
as a modifier key.) – Drew Apr 9 '17 at 15:27M-h
and then kill it or do something else with it. – user12563 Apr 9 '17 at 15:28