reddit / emacs
What do you use for very fast keybindings?
cidra_ · 2022-04-25 22:44
Hi all, I was wondering if any of you had any fast keybdinding for everyday actions that are very frequently used.
​
I am trying to find the keybindings that better fit my workflow but I'm really struggling with it: what I'm setting up is a very simple markdown editor and there are 4 things that i always do (bold text, italic text, math text, code text) but i just realized that the C-c prefix combinations are sooo slow for me.
​
What i usually did with traditional editors was something like C-b (bold) and C-i (italic) so i was insanely fast at it. I see that many keybindings besides the C-c prefix are already taken and it looks like overriding those is frowned upon. (Plus, C-i is basically <tab>).
​
So, back at the main question, is there some keybindings for some actions that you \*\*\*very\*\*\* often do use? How did you manage to set it?
11fdriver · 2022-04-25 23:04
Kind-of up to you I guess. You're free to move things around as it suits you. Don't try and adjust for Emacs, alter Emacs for you.
Since you have two actions you want to do, maybe try *M-p* and *M-n*. I sometimes bind actions I might want repetitively (like keymacros) to F5-F9.
You could also try moving *C-c* somewhere that you find easier to hit. You can use key-translation for that, or bind the key to `mode-specific-map`.
harmoniusplunge · 2022-04-25 23:18
If it's a possibility, you could try to use a hyper key. I have mine set to be my right alt key.
I have a lot of my own key bindings set to use a hyper key, so to go the beginning buffer `(global-set-key (kbd "H-a") 'beginning-of-buffer)` .
This way you don't have to deal with messing up any bindings you might want which are bound to (C-c).
Danrobi1 · 2022-04-25 23:43
Well, `M-x` ofcourse. `s-z` for `switch-to-buffer`. The `menu` key for `ibuffer`. I move around buffers with `s-arrow keys`. `C-c left/right arrow keys` for winner-undo/redo. `C-x left/right arrow keys` for `previous-buffer/next-buffer`. And `C-z`for my Personal Prefix-Command. Example:
(define-prefix-command 'z-map)
(exwm-input-set-key (kbd "C-z") 'z-map) ;; for exwm
(define-key 'z-map (kbd "u") 'elfeed-update)
(define-key 'z-map (kbd "s") 'bookmark-set)
(define-key 'z-map (kbd "j") 'bookmark-jump)
(define-key 'z-map (kbd "d") 'bookmark-delete)
notperm · 2022-04-26 00:05
You could just make yasnippets for the markdown stuff you do.
# -*- mode: snippet -*-
# name: Markdown Bold
# key: ** ;; or bold or b or whatever
# --
**$1**$0
gnuvince · 2022-04-26 00:29
I unmapped all of `M-0` to `M-9` since the effect can be obtained in many other ways (`C-u <number>` for instance) and I use them as prefix keys. M-1, M-2, M-3, and M-0 are particularly easy to type (M-0 requires two hands though) and I put a bunch of useful commands in there.
_viz_ · 2022-04-26 00:58
I use the super keys for this.
7890yuiop · 2022-04-26 01:32
I use:
* The Super modifier (aside from my relatively small number of window manager bindings, this is entirely free for Emacs use)
* `<menu>` as a prefix
* `C-z` as a prefix
* The standard user-reserved `C-c <letter>` sequences (some of which I can type faster than others) -- once again, often as a prefix.
Super and Menu are the fastest of the two. My super key is on the left and my menu key is on the right (they are in symmetrical positions on my keyboard), so I'm covered on both sides. I also use sticky modifier keys, so there's very little difference between a modifier and a prefix binding for me. I'd consider making the menu key into a Hyper modifier if that wasn't the case, though.
00-11 · 2022-04-26 01:46
> What do you use for very fast keybindings?
The best thing to use for fast key bindings: fast fingers? ;-)
(But there's sometimes an alternative of fewer key hits and maybe more time reflecting.)
00-11 · 2022-04-26 01:47
Or even the super-duper keys.
thetemp_ · 2022-04-26 03:14
Create your own prefix-key. It can be unmodified, so you don't have to hold down Ctrl, and all you have to do is tap it to access a world of unlimited personal keybindings.
Use either Kmonad or your OS's own customization features to put that prefix on CapsLock. I use Kmonad's `tap-hold-next-release` macro to get double use out of the key. Hold it down and it's a control key. Tap it and it's a <menu> key. I always hated CapsLock anyway, but that's personal preference.
The actual menu key already has a default binding, which is the same as M-x. So you can use a different key if you'd rather. There are at least 12 more function keys after f12, and I don't think any of them have a default binding (and most likely aren't using any space on your keyboard). So you could assign f15 to CapsLock and then bind that in Emacs as a prefix.
For markup, like surrounding text with stars or slashes, you can use `insert-pair`. It's made for brackets of course, but it'll work with any characters.
cazzipropri · 2022-04-26 03:14
I have an IBM M122 keyboard, with roughly 20 more keys to assign to functions I use frequently: https://github.com/scarpazza/battlecruiser
[deleted] · 2022-04-26 03:23
[deleted]
[deleted] · 2022-04-26 03:30
[deleted]
Status-Detective-783 · 2022-04-26 05:03
You might be interested in
https://github.com/emacsorphanage/key-chord
See various discussions:
https://www.emacswiki.org/emacs/KeyChord
https://google.com/search?q=key+chords+emacs
You might also want to invest in a good keyboard and possibly some macro type software for your OS.
ndamee · 2022-04-26 05:20
If you don't use C-b, etc for cusor movement, then you can rebind them. I do.
Even C-i can be rebound if you don't use Emacs on the terminal, because it is not needed in GUI emacs.
SaraBiYo · 2022-04-26 07:25
I use key-chord to "simulate" a leader key.
The idea is to press jk insert of something like SPC in normal mode in evil. Quite convenient.
(use-package key-chord
:config
(key-chord-mode 1))
;; this will be our leader
(unbind-key "C-z")
(bind-keys :prefix-map my-leader-prefix-map
:prefix "C-z"
("j k" . execute-extended-command) ; M-x
("SPC" . project-find-file)
;; b - buffers
("b b" . switch-to-buffer) ; C-x b
;;
;; more stuff
;;
("w s" . split-window-below) ; C-x 2
("w v" . split-window-right)) ; C-x 3
(key-chord-define-global "jk" 'my-leader-prefix-map)
cidra_ · 2022-04-26 07:34
Didn't know about Hyper key. It's free real keybinding estate. I might bind it to Caps Lock.
cidra_ · 2022-04-26 07:36
Snippets look great and looks easy to configure. I'm gonna check it out
cidra_ · 2022-04-26 07:41
That's a great idea to have different behaviour if double tapped or hold. I'm definitely gonna check it out.
Also, I never realized the purpose of that useless menu key so I'm definitely gonna try it out.
I'm already using electric pair :)
cidra_ · 2022-04-26 07:43
It's free real estate. A keyboard like that would never fit my desk :)
Ah, buon tortagiorno!
cidra_ · 2022-04-26 07:45
Looks great. I wonder how intrusive it would be.
I'm waiting for my mechanical keyboard to arrive. I can't wait!
cidra_ · 2022-04-26 07:46
So basically "jk SPACE" calls "project-find-file"? Looks cool
SaraBiYo · 2022-04-26 07:49
Yes, exactly.
ska352 · 2022-04-26 08:48
* In my personal, local settings I don't care if something is frowned upon. That's more for library authors.
* So, I override C-v and C-b as my "personal global" and "personal local" map, in parallel to C-x and C-b. Keycombos with control pressed and then 2 strokes are fast enough for me.
* For some very special commands I use key-chords. It integrates nicely with use-package and so a fast `JJ` becomes a pair of parentheses and `GG` calls magit-status
Status-Detective-783 · 2022-04-26 11:50
I don't have experience with it, but from what I've read, people are generally very happy with it. They've analyzed common key combinations to provide lists of combinations that won't conflict with words.
cazzipropri · 2022-04-26 11:57
Grazie!
RedditAlready19 · 2022-04-27 22:11
I can't bind to r-alt because that's my altgr key which I use to enter symbols
harmoniusplunge · 2022-04-27 22:41
You could try any of the other keys to the right of the space bar like the menu key or the right control key.
Or if you rebound control to caps lock you could make your left control into a hyper key. I believe this is pretty easy if you are on Linux.