Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>One other neat thing about _ is it will reliably select the whole token when you double click on it

Shout out and kudos to whomever brought that up



Frankly the fact that this doesn't happen with `-` in a `<code>` block should be considered a browser bug.


Well it doesn't happen in IDEs either (by default, at least)


I can see the argument for multi-line pre-formatted code blocks, but for inline `<code>` it would be nice if double clicking anywhere selected the whole thing.


I'd rather consistent behaviour TBH, I'm not too happy that `-` is a non-word character but I'd rather it always behaves the same everywhere without having to think about context


I wasn't quite aware of this because there are slight inconsistencies in some programs and between OSs.

e.g. in powershell on Windows, Ctrl+Backspace deletes the word part, but in cmd shell, Ctrl+Backspace deletes until whitespace. The keybindings to delete word also vary on Windows vs MacOS (Alt+Backspace deletes a word on mac, but deletes the whole line on Windows. Windows uses Ctrl+Backspace for that).

I was also confused since by-default Emacs doesn't treat `_` as a word character.


Is it `a-long-identifier` or is it `x-y`?


Ideally it’d use the language defined word separators. I fought for that in vscode but was out-voted :)


'-' is a minus sign. It will appear in code blocks much more often in contexts where you do want it to act as a word delimiter.


True, good point. Although if there are no spaces around it, it’s probably not acting as an operator. But at that point any heuristics to determine what it’s doing are well beyond the scope of the browser highlighting feature.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: