Hacker News new | ask | show | jobs
by robinh 4531 days ago
"In addition, I'm sure there are hunt and peck typists that still legitimately use caps locks instead of shift because it requires less coordination and hand contortions, so leaving caps lock alone also has accessibility benefits."

A recent poll I posted on HN suggests that I'm in the minority on this one, but I actually don't remap caps lock myself. And I like to think I'm a pretty capable writer, touch typing with a decent WPM.

Consider the following bit of assembly:

  .set MBOOT_PAGE_ALIGN,   1<<0
  .set MBOOT_MEM_INFO,     1<<1 
  .set MBOOT_HEADER_MAGIC, 0x1BADB002 
  .set MBOOT_HEADER_FLAGS, MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO
  .set MBOOT_CHECKSUM,     -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS)
(These are multiboot header definitions used by a kernel to get GRUB to load it, for the curious.)

I'm sure there are plenty of programmers who just use the shift key if they were to write code similar to the above, but I simply prefer the caps lock key myself. Habit, perhaps.

5 comments

For such code I would be holding down the Shift key with my left pinkie while I type the rest with all my other fingers.

That is (↓ meaning shift down and ↑ shift up):

    ↓mboot-page-align↑
The alternative would seem to be less effcient:

    <Caps>mboot↓-↑page↓-↑align<Caps>
I find holding down shift for large macro machinations to be a severe cause of pinky strain and awkward hand positioning. I don't do "perfect" home row style typing, but trying to hold left shift through that entire macro is borderline impossible for me to type -- I use my left pinkie for those As, and my left hand for reaching over to that B and that G, which is stressful holding left shift. For right shift, the underscore becomes especially problematic as well. On top of that, right shift (not left!) M has become muscle memory to the point where I reach for it even if I make the effort to hold down left shift for the entire identifier.

This results in, if optimized instead of tripping over my own fingers the entire time: ↓mboot↑↓-p↑↓age↑↓-↑↓align↑

My old iBook capslock key broke in half I hit it so often. I think my pinkies might break in half if I hit the shift keys at that rate!

Doesn't your editor have completion?

In Emacs I would end up typing '↑mb↓ M-/ M-/ M-/' (where Meta is the Option key on my keyboard). Because of the way Emacs completes, I might also do '↑mb↓ M-/ M-BS M-BS ↑P↓ M-/'. Either way that's easier to me that typing it out with caps lock or holding the shift key. The only time I can't complete is when I'm defining something for the first time and I'll get over it in that case since it's very rare.

> Doesn't your editor have completion?

Yes, but you'd agree it's no panacea, surely. - The main code editors I use all have slightly different completion mechanisms. Using a consistent non-IDE editor, while certainly possible, I find much more clunky than making do. I do use the completion of my primary IDE significantly however. - C++ completion is wonky in general due to the poor language grammar - I don't find defining things particularly rare. Every variable (local, member, or otherwise), every function, every class, every macro... - My muscle memory isn't built around the preprocessor, but around much more multi-context languages (such as C++) where entry as terse as yours will generally break regularly.

My mental state is brittle. Mis-completing identifiers breaks my flow and concentration, whereas typing is almost completely subconcious at this point having practiced it so regularly everywhere from this forum to my first clashes with 16-bit DOS programming. This means I could be seen as wasteful from a pure keystroke perspective on just about every front.

Even in the simple act of googling, I start entering my next, more refined search query while still scanning the results of my previous query. Dynamic search results broke this workflow (prompting me to disable Javascript) as my new text would cause the links I tried to click on to disappear because of the additional text entry, causing the results to refresh. I didn't even realize I was doing it until that change.

My use of completion is similar: Type until I scan the refined identifier to select as an early-bail. The closest I get to your completion style is some blind initial 3-5 character tokens + explicit use of completion keywords in some fairly limited contexts where I have a sufficiently low (1-4%?) failure rate. This translates to C-style free functions in C or C++, and C# members of things (classnames generally get typed out and then Ctrl+.ed for "using ...;" statement generation.) My macro names as a rule are too heavily namespace prefixed to blind-complete in that fashion, with the exception of some locally scoped 1-letter #define s which are #undef ed later in the same scope which need no completion.

While I've experimented with acronym-style completion methods rather than start-of-word-only, I find acronyming to require too much conscious thought, and disambiguation gives me outright struggle. If I'm in a context where the completion simply won't work (say that I haven't imported it yet like I thought I did), I have to go back and retype the entire thing.

> Yes, but you'd agree it's no panacea, surely.

You sound like you're using and IDE of some sort. I find their completion to be extremely useful when I can't remember exactly what function I want to call, but less useful when I know it and just want to get it typed out.

I use Emacs so I don't even have the nice semantic completion that IDEs offer (Emacs has some of that with its "cedet", but I can never figure out how to get it to work properly). But Emacs's completion heuristics are good enough for almost everything I do. When you hit the complete key in Emacs (M-/) it first looks backwards through the file you're in looking for the word. Then it looks forward. Then it looks in the other files you have open.

That looking backwards first thing is the key to why it works so well. And that's because most of the time you're referencing variable or macros that are nearby in your code, and almost always just up a few lines. It makes it correct a very high percentage of the time, so much so that I rarely completely type a variable name twice.

Like other people said, typing like that is very stressful for your hands. I wouldn't survive many hours typing like that. (This is one excellent use case for the Kinesis foot pedals.)
Actually, Caps Lock doesn't affect non-letter keys, so you don't need to hold Shift when typing the dashes.
Quite the opposite—because it doesn’t affect non‐letter keys, you need to hold Shift when typing the dashes, because they need to become underscores.
This is why I cross-remap _ and = .
Yes, for my part, I would really hope for autocomplete. Even if it comes down to enumerating all the MBOOT_ whatsit in a syntax file for my specific language, I would probably be willing to go that route.

Alternatively, Sublime Text supports multi-select. Ctrl-F, mboot[^\s]*\b and alt-enter to select all matches. Then use the command palette to convert to uppercase. Or ~ if you are using Vintage. But this isn't as good as autocomplete.

Anyway I have remapped caps and I miss it occasionally when typing constants. Usually I just hold down Shift, or use ~.

M-/ in Emacs will autocomplete it without enumeration/selecting/whatever
Ctrl+n is the vim equivalent, if anyone is wondering. Autocompletes tokens found in the current buffer.
You might want to use some help from your editor for this, e.g. auto completion. I'm hoping you never actually have to type every single letter of this code.
I don't remap it, either. I outright disable the key in the OS (simple option in OS X, registry edit in Windows).

As others have pointed out, once you hit a couple of underscores you're not gaining much with the caps lock (if anything), and your editor should be helping you out, here.

At the same time, I'm really not a fan of all caps and underscores, so I probably don't even use constants as much as I should.

Editors usually have a command to upcase the word, which is more convenient than caps lock. I would write it in all lowercase and then press ctrl-u.
Exactly. I haven't intentionally used capslock in 20 years.