5 ms·
> And forbidding it makes a one-keystroke action a two or four one. You can’t be serious
by Redoubts 3y ago
> And forbidding it makes a one-keystroke action a two or four one.
You can’t be serious
- jampekka 3y agoNot everyone wants a bloated and buggy IDE to write their code for them.
- geerlingguy 3y agoAlmost every text editor has support for tabs-as-spaces. I haven't used an IDE in years.
- wkat4242 3y agoI don't want that though. Because then when editing I still have to mess around with spaces. And the double nature of the spaces makes it hard to see when you have an odd number of spaces when you reach deep indenting levels, which counts as the lesser number of double spaces in Python. IMO it would be ideal if tabs would be displayed as a block, and you could resize the width of that block on the fly <3
- lkirkwood 3y agoLike vim, for example? Which supports replacing tab inputs with spaces...
- jampekka 3y agoI code practically exclusively with vim. The replacement is buggy and has many corner cases that come up constantly. As in all editors. Tab indentation has no bugs or corner cases.
- Two9A 3y agoAnd I've been using vim exclusively for north of fifteen years with Tab replacement, never had a problem with the editor getting confused about what happens with spaces when I hit Tab. Some detail about the corner cases you've run into would be great, if they're happening constantly I can see how it would be a bugbear.
- jampekka 3y agoFor example with vim (debian) defaults, if you happen to have a 2-space indented Python (the first two spaces are for HN formatting, the first if should start at zero indent): if True: # Two space indent And continue to add another if block in that, the autoindent will give you four spaces: if True: # Two space indent if True: # Four space autoindent And if you make a new line after the last row there and hit a backspace, it'll erase one space instead of four, giving an indentation of 3 (+2) spaces. And if you start a new line after that, you'll get an indentation of 8 spaces in total. Ending up with: if True: # Two space indent if True: # Four space autoindent # Hitting backspace gives this # Hitting a tab gives this This is just a one case, but things like this tend to happen quite often when editing code. Even if it's been originally PEP-8 indented. Usually it's not what the Tab does, but what the Backspace or Autoindent does. I'm not exactly sure what exact Tab/Backspace/Autoindent rules underlie the behavior, but I can imagine there having to be quite a bit of hackery to support soft-tabs. For me this kind of Tab/Autoindent/Backspace confusion is frequent enough that I'd be very surprised if others don't find themselves having to manually fix the number of spaces every now and then. And when watching over the shoulder I see others too occasionally having to micromanage space-indents (or accidentally ending up with three space indented blocks etc), also with other editors than vim.
- WorldMaker 3y agoAs with most things in vim, it is definitely manageable in settings such as tw=2 (tab width) and sts=2 (soft tab stop). This is why a lot of older Python files, in particular, are littered with vim modelines with settings like these. The nice modern twist is .editorconfig files and the plugins that support them including for vim. You can use those to set such standard language-specific config concerns in a general way for an entire "workspace" for every editor that supports or has a plugin that supports .editorconfig.
- theamk 3y agoWhen looking at the code, tab-containing files are the most inconsistent ones, especially when viewed via general tools (less, diff, even web viewers). Sure, if people would only ever use tabs for indentation and spaces for alignment, things could be good. But this almost never happens, instead: ... some lines start with spaces, some with tabs. This looks fine in someone's IDE but the moment you use "diff" or "grep" which adds a prefix, things break and lines become jagged. ... one contributor uses tabs mid-line while other use spaces. It may look fine in their editor with 6 character tabs, but all the tables are misaligned when looking in app with different tab size. Given how many corner cases tabs has, I always try to avoid them. Spaces have no corner cases whatsoever and always look nice, no matter what you use to look at the code. (the only exceptions are formatters which enforce size-8 tabs consistently everywhere. But I have not seen those outside of golang)
- wwweston 3y ago> Sure, if people would only ever use tabs for indentation and spaces for alignment, things could be good. But this almost never happens, instead: ... some lines start with spaces, some with tabs. People using tabs for alignment can happen when you've got a tab-camp-person who hasn't yet realized how they're terrible for alignment. But "some lines start with spaces, some with tabs" happens for precisely two reasons: * you have a codebase with contributors from both camps * people thought in-editor tooling was the solution (now you have two problems) > Spaces have no corner cases whatsoever This is tooling and (as you realized) stop preference dependent.
- deleted 3y ago[deleted]
- Larrikin 3y agoIs there any editor in 2024 that can't replace tabs with spaces? Is it just Notepad?
- magicalhippo 3y agoFor code I'd agree. However for configuration files, I find that I often need to edit them in places or environments where I don't have anything but the most bare-bones editor.
- lolinder 3y agoA quick search shows that even nano can be configured to use whatever number of spaces you want when you hit tab: https://askubuntu.com/questions/40732/how-do-i-get-spaces-instead-of-tabs-in-nano https://askubuntu.com/questions/40732/how-do-i-get-spaces-in...
- magicalhippo 3y agoI consider Nano a fully fledged editor. I'm talking Notepad or a html text box.
- lolinder 3y agoOh. Windows with no ability to install anything didn't even occur to me! I'm truly sorry.
- layer8 3y agoWhen this happens, I copy four spaces and then use Ctrl+V for Tab. Yes, it’s not exactly the same due to alignment, and yes you have to repeat it after using the clipboard for other purposes, but it’s good enough for that occasional use.
- Hikikomori 3y agoI prefer to keep my json to one line without white spaces, saves on disk space.
- coffeebeqn 3y agoJSON formatting is less important because most apps that deal with it come with good “beautify”, “sort”, “remove all formatting white space” functions in the editor
- Ygg2 3y agoI prefer to write to my disk manually with a magnetized needle in a clean room.
- eropple 3y agoClean room's for tryhards. Dust adds flavor.
- unkiep 3y agoI recommend you use smaller fonts as well.
- marcosdumay 3y agoOuch. The only problem with the obvious sarcastic tone of that comment is that there are plenty of people that do say exactly the same thing and mean it.