Is there a way to configure emacs, so that when I hit M-backspace it would actually remove the whole variable? If I have a variable like
my_dummy_variable I need to hit M-backspace three times in order to remove the name?
You can use the built-in
(global-set-key (kbd "M-DEL") 'backward-kill-sexp)
This has the unwanted effect of adding whatever was deleted to the kill ring.
To fix this you can try:
(defun backward-delete-sexp (arg) (interactive "P") (delete-region (point) (progn (backward-sexp arg) (point))))
I think you're looking for
superword-mode. From its documentation:
Superword mode is a buffer-local minor mode. Enabling it remaps word-based editing commands to superword-based commands that treat symbols as words, e.g. "this_is_a_symbol".
The superword oriented commands activated in this minor mode recognize symbols as superwords to move between superwords and to edit them as words.