7 ms·
I do prefer snakecase visually but having to press shift for the underscore is a pain and it’s also quite far from the home row on the keyboard. I wonder if a
by stevula 4y ago
I do prefer snakecase visually but having to press shift for the underscore is a pain and it’s also quite far from the home row on the keyboard.
I wonder if a lot of people rebind the underscore character to a more convenient key?
- simonblack 4y agobut having to press shift for the underscore is a pain But having to press shift for a capitalised word is not a pain. OK, sounds about right.
- stevula 4y agoHa! You got me there.
- irrational 4y agoFor me it is easier/faster to type uppercase letters than an underscore. But, I have small hands.
- kitsunesoba 4y agoSame. I'm noticeably faster with camelCase.
- timbit42 4y agoThat's why kebab-case-is-best.
- inDigiNeous 4y agoWell, this-case-has-the-problem-of-mixing-with-the-letters-more-easily. When you type snake_case it is clearly not in the line of the letters. But yeah kebab-case-might-be-easier than camelCaseToRead in the long run.
- shrimp_emoji 4y agoThis haunts me. It seems almost as good as snek_case but doesn't require a Shift. If we're not Shifting the letters, why are we shifting the -s? My OCD. (Or my autism?) Help. Another consideration: whether the program you're typing in will stop at underscores or hyphens when using Ctrl + Shift + Left/Right Arrow when highlighting. If I want to highlight `this_variable_with_a_long_name` without using the mouse, it's going to be a pain if I have to hit the left arrow key six times instead of once. (Frustratingly, it varies from editor to editor.)
- fiddlerwoaroof 4y agoThis might be configurable: vim and emacs, at least, let you define which characters are part of a word.
- askvictor 4y agoBecause many languages don't require whitespace between symbols (e.g. x) and operators (e.g. +). So in Python, x+3 is valid (x plus three). As is x+y. And x-y. So how does the interpreter/compiler know if coffee-bean is a single variable, or an operation (coffee - bean) between two variables?
- brookst 4y agoSounds like job security! x-y = ‘a string or something’ # # bunch of lines of code here # x = 5 y = 2 assert x-y == 3
- eyelidlessness 4y agoThe reason we (most of us) can’t have kebab-case is the same reason it mostly occurs in lisps and other declarative syntaxes: infix operators. ie if you can have identifiers or keywords like-this and you can also have subtraction like-this, you have some serious syntax ambiguities to deal with. As far as keyboard navigation around partial or whole words, I find it really helpful to have separate keybindings. For me (on a Mac so keyboard layouts matter), opt+left/right moves a “whole word” (as in to the nearest non-word character) and ctrl+left/right moves to the nearest internal word boundary (where boundary is mostly arbitrary; in bouncyCase it moves to the nearest non contiguous case change, in any-punctuated_case it moves to the nearest punctuation). Agree it’s frustrating how much this varies by editor, but being able to configure the behavior is one of my first checks when deciding if I’ll use the editor at all.
- simonblack 4y agokebab-case is all very well as long as a hyphen is not treated as the 'minus sign' Many years ago, I was programming in COBOL, where kebab-case is the norm. For a while there I was programming in both "C" AND in COBOL. That was a nightmare, I invariably used the wrong syntax for my variable-names, as both languages used incompatible syntax for those variable-names.
- bostonvaulter2 4y agoI've bound underscore to a top-level key in my default keymap. It's made a big difference to me!
- layer8 4y agoThe position of the -/_ key is a bit awkward relative to the right-hand shift key in the US layout.
- snozolli 4y agoYou skipped the important half of the sentence: and it’s also quite far from the home row on the keyboard. I'm not going to adopt a coding style that requires me to reach that far repeatedly for every name.
- gpderetta 4y agokebab-case-would-be-the-best-but-it-is-unfortunately-not-supported-by-most-languages
- stevefolta 4y agoIndeed. I wouldn't have a strong preference between snake_case and camelCase, but I use snake_case for new code because it's closer to kebab-case.
- dahfizz 4y agoThis makes me feel uncomfortable
- b112 4y agoYou and me both, brother. Also.dot.case.wins.all.
- SAI_Peregrinus 4y agoAnd—long—kebab—case—isn't—well—supported—by—most—keyboards.
- eyelidlessness 4y agoWorks great on Macs, and the default layout makes it an easier reach than underscores!
- SAI_Peregrinus 4y agoThose are "em" dashes, not hyphens. Shift+Option+- is harder than Shift+-.
- eklitzke 4y agoObviously you should swap the bindings for _ and - (so you press shift for dash instead of the other way around). If you're really perverse you can do the same for 9/( and 0/), because most programmers type parens way more often than the type 9 or 0.
- deleted 4y ago[deleted]
- bitwize 4y agoHaving to press shift shouldn't matter much except when you are introducing a new identifier because your autocomplete should kick in after you type the first couple of characters. (You are using an IDE, right?)
- 8jy89hui 4y agoI bound _ to capslock + u. It is very convenient for both hands.
- hgs3 4y ago> I do prefer snakecase visually but having to press shift for the underscore is a pain Code is written once but read many times. Better to optimize for reading than writing.
- Pxtl 4y agoMy dream is a programmer's keyboard where part of the spacebar is underscore. Also add A-F to the 10key numerical keypad.
- smcameron 4y agoRemember those keyboards with a split space bar? I don't know what they were meant for, but I always thought it would be cool to map one of them to underscore. Never had such a keyboard myself though.
- nlnn 4y agoI thought about this, but realised that I don't spend that much time typing when coding. Maybe when defining a new variable/class/etc. the first time, then IDE autocomplete fills it in the next.
- gsinclair 4y ago> I wonder if a lot of people rebind the underscore character to a more convenient key? I create bindings using Karabiner (Mac) for all symbols so that I don’t have to press Shift or leave the home position. Underscore is “s comma”.
- cassepipe 4y agoI personally like the underscore because it is always the same combination while Caps are combinations all over the place and you have to choose the most convenient shift key, left or right.