5 ms·
> Like, just to calibrate here: you know how some code editors will automatically fill in a right bracket or quote when you type a left one? You type " and the
by chrismorgan 1y ago
> Like, just to calibrate here: you know how some code editors will automatically fill in a right bracket or quote when you type a left one? You type " and the result is "|"? Yeah, that drives me up the wall. It saves no time whatsoever, and it’s wrong often enough that I waste time having to correct for it.
I have not yet figured out why anyone would choose this behaviour in a text editor. You have to press something to exit the delimited region anyway, whether that be an arrow key or the closing delimiter, so just… why did the first person even invent the idea, which just complicates things and also makes it harder to model the editor’s behaviour mentally? Were they a hunt-and-peck typist or something?
In theory, it helps keep your source valid syntax more of the time, which may help with syntax highlighting (especially of strings) and LSP/similar tooling. But it’s only more of the time: your source will still be invalid frequently, including when it gets things wrong and you have to relocate a delimiter. In practice, I don’t think it’s useful on that ground.
- sonofhans 1y agoPreach it. I’d rather hit right bracket than right arrow.
- arkh 1y agoMaybe the origin is the fact not everyone uses qwerty mappings. On a french keyboard, ~#{[|\\^@]} all require the "alt gr" modifier key which is usually just right of the space key. So totally outside the realm of shift, caps lock, ctrl or alt.
- atemerev 1y agoBecause otherwise it would break syntax highlighting until you finish writing the string. And no, sorry, I like my syntax highlighting, I won't turn it off. This feature is useful for me. So are LLMs. If someone doesn't want to use this or that, they are not obliged to. But don't tell me that features that I find useful "suck".
- willvarfar 1y agoSad this is downvoted, because syntax highlighting is a very plausible explanation for this editor behaviour. You can perhaps imagine an editor that only inserts the delimiter if you type the start-string symbol in the middle of a line.
- chmod775 1y ago> Because otherwise it would break syntax highlighting until you finish writing the string. You can always insert the second " as a ghost(?) character to keep syntax highlighting working. But it's not like any modern language server really struggles with this anyways.
- BlindEyeHalo 1y agoI think it is practical when highlighting text and then pressing " once puts quotes and the start and the end of the highlighted region. But I agree that in normal input it is often annoying.
- matejn 1y agoI hate that even more, especially since Visual Studio introducted it. I had the habit of selecting some text, and then typing to replace it. Now when my replacement starts with a parenthesis or quote, the text just gets surrounded instead! Maybe this is just an XKCD moment https://xkcd.com/1172/ https://xkcd.com/1172/ ...
- jeffhuys 1y agoI think for the feature of wrapping, it is useful enough + just typing a->backspace->" is easy enough that I think it's a net win
- pxc 1y agoBut there have been sensible bindings for doing this forever, e.g.: https://github.com/tpope/vim-surround https://github.com/tpope/vim-surround There's no need to break normal editing behavior.
- tehnub 1y agoPair programming with coworkers over the years, many seem to have trouble with the keyboard, to the point where pressing right parenthesis is a significant burden and they don’t use right or down arrow to get out of the span but actually move their hand to their mouse and click out.
- piker 1y agoOkay, so optional accessibility issue?
- Cthulhu_ 1y agoI've said it in another comment (might be here or Reddit, I don't even know anymore) and it feels like basic skills are just overlooked or taken for granted these days - computer use, mouse / keyboard / typing skills, reading comprehension, writing ability, communication skills, etc. I'm nowhere near a hiring position but if I was I'd add assessing that to the application procedure. It feels like this is part of a set of growing issues, with millennials being the only generation in between gen X / boomers and gen Z that have computer skills and can do things like manage files or read a whole paragraph of text without a computer generated voice + RSVP [0] + Subway Surfers gameplay in the background. But it was also millennials that identified their own quickly diminishing attention spans, during the rise of Twitter, Youtube, Netflix and the like [1]. I want to believe all of this is giving me some job security at least. [0] https://en.wikipedia.org/wiki/Rapid_serial_visual_presentation https://en.wikipedia.org/wiki/Rapid_serial_visual_presentati... [1] https://randsinrepose.com/archives/nadd/ https://randsinrepose.com/archives/nadd/ (originally published 2003, updated over time to reference newer trends)
- nyarlathotep_ 1y ago> read a whole paragraph of text without a computer generated voice + RSVP [0] + Subway Surfers gameplay in the background Quite literally laughed out loud at this. I still cannot believe this is a thing people actually do; I thought it was a joke "genre" at first.
- thasso 1y agoI'm shocked every time I go to City Hall and wait while the clerk types my name letter by letter with two fingers. Doesn't he do that every day?! How as it never occurred to him or anyone else that maybe, just maybe, they would benefit from a typing course. It’s just one example of a pattern I’ve noticed with a lot of office workers.
- cess11 1y agoMy REPL-style interfaces don't have it while my editors do, I don't feel either is particularly special and there are little pros and cons with both.
- _thisdot 1y agoI have this turned on in my code editors and Obsidian. The main advantage is reducing the cognitive load. You don’t have to double-check whether you remembered to close your string, bracket, or parenthesis — it’s just there.
- elric 1y agoThe cognitive load of typing two quotes? Golly. That term is starting to take on "whatever" meaning, apparently.
- _thisdot 1y agoThe cognitive load of keeping track of all the open delimiters. In my perceived experience, every time a delimiter is opened, it automatically closes, allowing you to move away from it without thinking. Even in places where this is not available (Slack, comment boxes, etc.), I close the delimiter as soon as I open it
- Cthulhu_ 1y agoYou don't have to anyway, a syntax error will show up on your screen pretty much immediately.
- _thisdot 1y agoWhich I'd like to avoid as early as possible
- rasur 1y agoEmacs user here, and the whole "electric-mode" stuff (for matching parens or other balanced pairs of things) I find really quite useful. And closing a pair is usually something like shift+enter, which is quite simple (but also - at least in Emacs - generally completely configurable). I think the benefits outweigh the pitfalls, personally. Can't speak to other editors though.. I don't want to sound like I'm trolling, but they generally feel quite clunky, compared to Emacs (ducks, runs ;p )
- b112 1y agoThere's nothing wrong with emacs. Both vim and emacs are just targeting different segments of humanity, that's all. Vim is clean, concise, slim, where as emacs is more bulky, cluttered, stifling. It's just matching, and reflecting the way different humans think, and reason, that's all. (yes, said in jest)
- matsemann 1y ago> and it’s wrong often enough How is it ever wrong, though? If I insert a (, and then a {, and the editor appends so that it's ({}), that's always ?correct. Can it ever not be. Maybe because on a Norwegian keyboard { is a bit awkward, but I like it. Then even if we're 5 levels deep with useEffect(() => {(({[{[ I can just press ctrl+shift+enter and it just magically finishes up everything and put my caret at the correct place, instead of me trying to write ]}]})) in the correct order.
- rcxdude 1y agoIt certainly can, because it doesn't necessarily know where the closing brace should be, especially when inserting as opposed to writing a completely new line. I'm often deleting random crap in the editors I use with the 'feature' as I'm adding delimiters. '"' tends to be even worse, because the distinction between opening and closing is not obvious. e.g.: (a + b > c) -> ((a + b > c) -> (()a + b > c) -> no, I was aiming for ((a + b) > c) (it sound like you're talking about a different feature/implementation, though, since in the annoying case there's no 'completion' shortcut, it just appears)
- jltsiren 1y agoMost editors are not smart enough to do it consistently right. For example, VS Code often inserts extra quotes when I try to break "long string" into "long " + something() + " string". And when I try to write a half-open interval [a, b) in a comment or within a string, the editor inserts an extra ].
- Kon5ole 1y ago>How is it ever wrong, though? Whenever you edit something existing that already has the ), ] or } further down and you end up with a ()), []] or {}}. Or when you select some text that you want to replace and start with a quote only to end up with "the text you wanted to replace" instead of the expected ". I never notice when it works but get annoyed every time it doesn't, so I feel like it never works and always sucks. I guess it's muscle memory and some people are used to it, but it feels fundamentally wrong to me to have the editor do different basic editing things based on which character is being pressed.
- 1y ago
- 8n4vidtmkvmk 1y agoI hated this feature until I realized I could just type the closing quote anyway and it wouldn't double up. Doesn't seem to bother me now that I'm used to it. Once in awhile my editor tries to get too clever and messes things up, but not often
- whoisyc 1y agoThat’s what GP said about “harder to model the editor’s behaviour mentally” though. In a dumb editor you type a quote and you get a quote, in a “smart” editor whether or not you get two quotes, one quote, or no quote at all is context dependent and more confusing.
- deleted 1y ago[deleted]
- feelamee 1y ago> You have to press something to exit the delimited region anyway, whether that be an arrow key or the closing delimiter, so just… Hah, fun about this is that I press exactly the matched symbol ( `}` to `{` , etc) to exit this delimited region and VS even understand what I want! Incredibly useless thing
- kqr 1y agoI've never noticed some editors do this because I always type both opening and closing symbols at the same time, and then back up into them if I want to fill them out. I think I learned it from my father and just anecdotally I make mistakes of unbalanced symbols nowhere near as often as others.
- pxc 1y ago> But it’s only more of the time: your source will still be invalid frequently, including when it gets things wrong and you have to relocate a delimiter. In practice, I don’t think it’s useful on that ground. Maybe it's like a pale imitation of structural editing? There are editing modes for some editors that more or less ensure the syntax is always valid as you edit, and they of course include this feature.