0

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.

1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.