8

My system is debian wheezy, I tried to do the following

(global-set-key (kbd "S-<backspace>") 'evil-shift-left-line)
(global-set-key (kbd "<S-backspace>") 'evil-shift-left-line)
(define-key global-map [S-backspace] 'evil-shift-left-line)

What I want is in evil insert mode, I can delete one tab width forward instead of press backspace 4 times. The keybinding works on my laptop, but doen't work on my desktop. I check the binding for evil-shift-left-line, it has changed but doesn't work, and help on "shift-backspace" only shows "backspace". However, shift do has effect on "backspace", "shift-backspace" delete the previous word instead of character.

When I insert "shift-backspace" after "C-q", it has the same notation "^?" as "backspace" on my desktop, while on my laptop the former is "^@".

Any ideas on why it doesn't work on my desktop? Thank you for your help!

This question may be related to this one: Shift+Up isn't recognized by Emacs in a terminal

godblessfq
  • 1,177
  • 8
  • 21

3 Answers3

6

Interestingly, you can try binding the deletechar pseudo key.

When I check the binding of backspace on my machine with C-h k [backspace], I get:

DEL (translated from <backspace>) runs the command... (blah blah blah)

When I check the binding of shift + backspace on my machine with C-h k S-[backspace], I get:

<deletechar> (translated from <delete>) runs the command... (blah blah blah)

The following therefore works on my machine:

(global-set-key [deletechar] #'evil-shift-left-line)
Dan
  • 32,584
  • 6
  • 98
  • 168
2

I have this in my setup:

(define-key global-map [(shift backspace)] 'backward-delete-whitespace)
(define-key global-map [(shift delete)] 'forward-delete-whitespace)

to make shift+backspace / shift+delete kill all whitespace.


And just in case someone would need these functions, here they are:

(defun backward-delete-whitespace ()
  (interactive)
  (let ((p (point)))
    (re-search-backward "[^ \t\n]+" nil t)
    (forward-char)
    (delete-region p (point))))

(defun forward-delete-whitespace ()
  (interactive)
  (re-search-forward "[ \t\n]+" nil t)
  (replace-match "" nil nil))
mishoo
  • 249
  • 2
  • 5
1

I am now happy with this setting.

(defun my/backspace()
  (interactive)
  (if (string-match "[^[:space:]]+"
                    (buffer-substring-no-properties
     (line-beginning-position) (point))) ;; return nil no match
      (backward-kill-word 1)(evil-shift-left-line)))
godblessfq
  • 1,177
  • 8
  • 21