6

I'd like to bind to control-minus in my .tmux.conf but it doesn't seem to work:

bind C-- split-window -v

Is this possible?

5
  • A lot depends on your terminal and how it interprets the keys it receives. For example for me it works in XTerm with the hyphen (that is the key found to the right of zero on the main section of the US keyboard), but not with the one on numerical keypad. In Konsole it doesn't (after removing the default key binding that shrinks the font). On Linux console it doesn't work either. That said, it is probably wiser to find other key combination - have you thought of C-\ and C-| for horizontal and vertical splits?
    – peterph
    Sep 29, 2014 at 19:37
  • bind C-_ split-window -v
    – jasonwryan
    Sep 29, 2014 at 19:41
  • @jasonwryan wouldn't that bind to Ctrl + underscore?
    – peterph
    Sep 29, 2014 at 20:31
  • @peterph no, it works for minus.
    – jasonwryan
    Sep 29, 2014 at 20:31
  • @jasonwryan it does not work for minus, if you are using Alacritty.
    – Yuki
    Mar 1, 2021 at 12:04

1 Answer 1

8

The C- notation doesn't refer to actual keyboard hardware combinations. They refer to ASCII control codes. Historically, the notation was used to indicate ASCII characters between 0 and 31 by subtracting 64 from the ASCII value of the character used in conjunction with C-. For example, C-@ represents ASCII 0 (NUL) because @ is ASCII 64; C-G represents ASCII 7 (BEL) because G is ASCII 71; etc. In other words, you generate ASCII x (for x between 0 and 31) by holding the Control key while pressing the key for ASCII x+64.

You'll notice that - (ASCII 45) is too small to subtract 64 from! So technically, C-- does not exist as a character. The only "real" control characters are C-@ though C-_. However, having to hold down the shift key is a little cumbersome, so typically you can type the lowercase letter instead (that is, Control-Shift-a and Control-a are equivalent). Since - and _ are on the same key (at least on my US QWERTY keyboard), C-_ can be used to represent the character generated by either Control-Shift-- or Control-_.

(This doesn't explain why C-- and C-_ are not equivalent while C-a and C-A are. I suspect that while nearly every keyboard will have a and A on the same key, the same is not true for -/_.)

3
  • I was originally using C-_ but didn't want to have to hold down the shift key. Indeed you're right, it recognizes it without the shift anyways! Thank you
    – ivan
    Sep 29, 2014 at 21:16
  • It's also possible that if your keyboard has something other than _ on the same key as -, you would use that. Probably a more-correct answer is that you can only use Control + - if - lives on the same key as something in ASCII range 64-95.
    – chepner
    Sep 29, 2014 at 21:18
  • Is is tmux specific interpretation of C- notation? What if I want to bind C-- to one thing and C-_ to another?
    – Yuki
    Mar 1, 2021 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .