In this blog post, you will learn how to run Qt Creator in emacs-mode or in layman terms how to configure GNU Emacs keybindings in Qt Creator.
Why I write this blog post
This mini-tutorial is a note to my future self, searching how to configure Qt Creator to behave like Emacs all over the internet after another system reset.
At the same time, it might serve useful for anyone else looking for the same thing on the web.
Now you might ask why I want to run Qt Creator in Emacs mode anyways. My answer is quite simple: Qt Creator is an excellent IDE, but I like Emacs as text editor better. Since I don't want to switch between different key configurations all the time, it makes sense to configure Qt Creator to behave like Emacs.
Well, and after getting used to the Emacs Ctrl-Meta-Key fu, it kinda starts to feel natural navigate with Ctrl-n,p,f,b
and to switch between frames with Ctrl-x-o
.
Activating the emacs-mode
To activate the emacs-mode in Qt Creator is simple with a recent version of Qt Creator which also comes with the Qt SDK.
The EmacsKeys plugin by nsf provides the basis for the Emacs keybindings in Qt Creator. To activate it just open the About Plugins... window via the menu Help > About Plugins...
.
Then you need to add the checkmark next to the plugin in the Installed Plugins window. After restart Qt Creator you are ready to configure the Emacs keybindings.
If you have thought that you can use the Emacs key combinations right after activating the plugin, then you have made the same mistake as me after first activating the plugin.
The EmacsKeys plugin provides new command for Qt Creator so it can be configured to behave like Emacs. However, it does not touch the keyboard shortcuts at all.
Luckily you can configure the Qt Creator keyboard shortcuts quite easily via the settings menu Tools > Options...
in Environment > Keyboard
.
Setting all the Qt Creator Command to match a keybinding for something similar in Emacs requires some handwork. To save you some time configuring the keybindings all by yourself I uploaded a sane configuration to GitHub Gist: Emacs.kms.
Import the file and voila - you will be running Qt Creator in emacs-mode.
Conclusion
Configuring Qt Creator to work in emacs-mode is easy if you know how to do it and worth the effort. Now I can enjoy an almost mouse-free Qt Creator experience, especially useful when traveling.
I hope you have enjoyed reading this blog article and I would very much appreciate any feedback and comments.
Your
Machine Koder
Comments 7
I really appreciate you sharing this.
This is amazing. Thank you so much!
Perfect! Thanks 😉
Thank you! Works very well
I'm sorry. Your gist isn't working for me. I'm an original Emacs user (from the '90s). Your gist, when imported, doesn't use standard key sequences (like Esc,W for Copy). For some reason Ctrl ended up Cmd when imported and other differences from standard key bindings. So thanks for pointing out the 'experimental' EmacsKeys. It was easy enough to walk through them once and find other key bindings I wanted. I'll keep looking online to see if there another keymap, but its not that difficult. I also use tags (goto function def, goto function def other window).. i.e. "meta-." which came from lisp machines and AI.
Sorry if I'm missing something here.
Please sure when you have created a new-and-improved .gist.
Thanks, Bill!
Great! Thank you!