I would like to use Ctrl + Tab in EMACS for my own use, but Emacs org mode already has this bound. How can I use my own binding instead of the org-mode binding.
In my .emacs file I use:
(global-set-key (kbd "<C-tab>") 'switch-view )
and it works everywhere except in org-mode
A more robust way to set the keybindings that you want to take effect everywhere regardless of the major mode is to define a global minor mode with a custom keymap.
( http://www.gnu.org/software/emacs/manual/html_node/emacs/Local-Keymaps.html )
That way you don't need to mess with the major mode's local keymap every time you encounter a mode that clobbers your keybinding.
See this Q&A for details:
Globally override key binding in Emacs
This doesn't work because, as you said, org-mode uses its own keybinding for C-TAB. In other words, even if you define a global keybinding, as soon as you invoke org-mode, it will overwrite that binding with its local keybindings.
What you can do, however, is add a callback function that is invoked whenever you start org-mode, and in that callback function you reset C-TAB to invoke switch-view:
Put the above line in your .emacs file and next time you start a new Emacs you should be good to go.
The key binding you describe is defined in
org.el
like this:This means that it is only valid in
org-mode-map
, one of org-mode's local keymaps. The following code adds a hook that is run when org-mode starts. It simply removes that key binding fromorg-mode-map
.Add this code to your .emacs file and then restart emacs.