1

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.

Basil
  • 12,383
  • 43
  • 69
sandric
  • 1,271
  • 9
  • 20

1 Answers1

2

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)
Basil
  • 12,383
  • 43
  • 69