Search code examples
emacskeyboard-shortcutskey-bindings

bind 'indent-to-column' to C-tab


I'm trying to bind indent-to-column 100 to C-TAB (or even just indent-to-column so I could then enter the column number I want), but what I tried isn't working:

This gives me an error when I open emacs:

(global-set-key (kbd "<C-tab>") 'indent-to-column 100)

This seems to have no effect:

(global-set-key (kbd "<C-tab>") 'indent-to-column)

What am I doing wrong?


Solution

  • Your second expression should work (in that it should bind indent-to-column to C-TAB, but you still have to provide the argument). You can check this using the following key sequence to see what C-TAB is bound to:

    C-hkC-TAB


    If you want to provide the argument as well, you can use this kind of construct:

    (global-set-key (kbd "<C-tab>")
                    (lambda ()
                      (interactive)
                      (indent-to-column 100)))