How to remap shift-arrow in term-mode?

Is there a way to map Shift-left or other arrow keys to custom functions in term-char-mode?

I tried, but without luck:

(define-key term-mode-map [s-left] 'sandric/term-switch-line-mode)

Entering Shift-left in my terminal gives [1;2D, so I also tried:

(define-key term-mode-map "[1;2D" 'sandric/term-switch-line-mode)

But that also does nothing.

 

ANS:

Is there a way to map Shift-left or other arrow keys to custom functions in term-char-mode?

There is indeed.

(define-key term-mode-map [s-left] 'sandric/term-switch-line-mode)

Two issues here:

  1. term-mode-map is the keymap used by line mode, whereas char mode uses term-raw-map.

  2. [s-left] (lowercase s) corresponds to the <Super> modifier. The <Shift> key is abbreviated as an uppercase S, as in (kbd "S-<left>") or [S-left].


So the solution to your problem is likely

(define-key term-raw-map [S-left] #'sandric/term-switch-line-mode)



reflink: https://emacs.stackexchange.com/questions/37093/how-to-remap-shift-arrow-in-term-mode
https://www.stacknoob.com/s/osEnkacehHy7WHVquzRgdL
posted @ 2020-06-02 16:37  ls1519🎈  阅读(113)  评论(0)    收藏  举报