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?
Asked
Active
Viewed 109 times
1
-
4Maybe the answers to this [question](http://emacs.stackexchange.com/questions/983/treat-symbols-as-words-in-prog-modes) can help. – Nsukami _ Feb 27 '16 at 18:16
-
this is really related to emacs not C and not C++, suggest remove `c` tag, – user3629249 Feb 28 '16 at 01:02
2 Answers
2
You can use the built-in backward-kill-sexp
.
(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))))

erjoalgo
- 853
- 1
- 5
- 18
-
-
`(let ((kill-ring)) (backward-kill-sexp arg))` may be a cleaner solution. – PythonNut Feb 28 '16 at 22:43
1
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.

Aaron Harris
- 2,664
- 17
- 22