You can’t be serious
You can’t be serious
https://askubuntu.com/questions/40732/how-do-i-get-spaces-in...
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.
I haven't used an IDE in years.
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
Tab indentation has no bugs or corner cases.
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.
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.
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.
With Tabs we wouldn't have this yet another papercut to tool over.
(It is one of the arguments for using hard tabs instead of soft ones in the eternal tabs versus spaces debates because editors can show hard tabs as different space equivalents as a user "style choice" without affecting the underlying text format.)
Vim has no autodetect by default. (I'm sure there's a plugin somewhere.)
Another comment suggests it's using 2 and 4 for different settings and that's causing problems.
Backspace doesn't unindent in vim by default, it removes spaces one at a time. That's a difference between the ts=4 (tab stop) and sts=4 (soft tab stop) is sts also applies to backspace. But the default is that it doesn't because the out of the box default believes that backspace operates on physical characters (spaces) not soft/fake ones (tabs expanded to spaces) by default.
I don't know if that is the right default, and it is definitely a baroque exercise to get all the settings right for some languages, but there is a consistency to the defaults even if those defaults don't meet some modern expectations from newer code editors.
(Also, I just realized above I confused tw [text width] and ts [tab stop]; my vim skills are rusting a little.)
if !exists("g:python_recommended_style") || g:python_recommended_style != 0
" As suggested by PEP8.
setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4
endif
So if you use "set sw=2" then it leaves tabstop and softtabstop at 4.You can set that g:python_recommended_style to disable it.
Also sw=0 uses the tabstop value, and softtabstop=-1 uses the shiftwidth value.
I agree Vim's behaviour there is a bit annoying and confusing, but it doesn't really have anything to do with tabs vs. spaces. I strongly prefer tabs myself as well by the way.
Even when you DO use tabs Vim will use spaces if sw/ts/sts differ by the way. Try sw=2 and using >>, or sts=2 with noexpandtab.
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)
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.