reddit / emacs

Is there any easier way to type parens

drrnmk · 2022-01-29 00:09
Hi! I write Clojure and common Lisp and have been feeling tired to type parens by shift+8 all the time. Is there any easier way to type it? It'd be even better to be able to just use one key so I'm not sure if it is possible. Please enlighten me if you have any clue. Thanks.
ieure · 2022-01-29 01:32
Simple answer: `M-(`, `insert-parentheses`. Give it a prefix argument and it'll wrap the parens around that many expressions, which is terrific. Complex answer: [paredit](https://www.emacswiki.org/emacs/ParEdit) probably has something.
iwaka · 2022-01-29 02:59
Yes there is: space cadet parens. You know how people rebind their CapsLock to be Control when held down and Esc when tapped? (And if you don't, you should try it, it's awesome.) Well, you can take the same idea and apply it to other modifier keys! Your Control, Alt, and Shift keys do nothing if you just tap them. That's a waste of keyboard. Get them to work by binding keys to them when tapped! To be specific, **bind the opening and closing parentheses to left and right Shift, respectively**. The "space cadet" name comes from an old keyboard that had this setup. It was apparently a favourite with old-timey Lispers. The specific way you'd do this depends on your setup and OS. If you have a programmable keyboard, you can do this through your keyboard's firmware. If you don't, there are software solutions too. Edit: this also works in tandem with other solutions mentioned here such as paredit and friends. Many ways to make your life easier!
varsderk · 2022-01-29 05:05
If you have a keyboard that supports QMK, it should be easy to enable "space cadet shift" or the like. I've got open paren when I tap left shift and close paren on right-shift. (They both act as regular shift if I hold it—though now that I've made `v` and `m` into shift when I hold them, I don't use those keys as shift; just dedicated parens now, I guess.) Some things you can fix with Emacs config. Other things you gotta go via your input medium. IMO, Emacs is best used with an ergonomic keyboard that has a bunch of keys for you to press with your thumbs. Not for everyone, but definitely a thing for a lot of people.
flora_best_maid · 2022-01-29 10:42
You can configure your keyboard layout (in software) to place parentheses in more ergonomic positions. Ideas: - replacing keys you rarely use - swapping number row and their symbols. That means you'll need the shift key (or caps lock) to type numbers. - swapping brackets or braces with parentheses. - configuring a key to be a third layer key. That way you can put parentheses on the home row. You do this through xkb in Linux and MSKLC in Windows.
7890yuiop · 2022-01-29 21:59
If your keyboard layout is like mine, you have the following four keys: ( ) { } - shifted 9 0 [ ] - non-shifted Without affecting any other keys, you can consider which of the three pairs you use the most, and simply make *that* the non-shifted pair, and shuffle the others accordingly.
genehack · 2022-01-30 16:47
The Space Cadet keyboard didn't have parens on the shifts; the practice of doing this is called "space cadet parens" because it was first discussed in a blog post called [A Modern Space Cadet](https://stevelosh.com/blog/2012/10/a-modern-space-cadet/). That article is, in general, good reading if you're interested in improving your keyboarding experience — in particular, the thing about forcing yourself to use the "correct" shift key is fantastic.
iwaka · 2022-01-31 06:25
TIL! Thanks for the articleb link, that's some great reading.