4 ms·
What external tool can't interpret a \t character correctly? To me, the problem is consistency. I'm a 4 space man myself, but tabs don't outright offend me, a
by diminoten 13y ago
What external tool can't interpret a \t character correctly?
To me, the problem is consistency. I'm a 4 space man myself, but tabs don't outright offend me, as long as they're everywhere. I'd rather commit edits with tabs than attempt to convert the whole project to spaces, or worse, commit some spaces and some tabs to a single file/project.
- pjmlp 13y agoFor example when everyone has a different meaning how many spaces a tab represents, you end up with multiple amounts of tabs on your files. This fully breaks the indentation, which is exacerbated when multiple teams working on the same code basis use different editors and tab settings. So in the end one needs to rely on external tools that go over the source code to normalize the use of tabs.
- raverbashing 13y agoNo, that's what a coding style is for. Either specify tabs or spaces and you enforce it A tab means 8 spaces. If you want your editor to show something different that's up to you, but it's non standard.
- pjmlp 13y agoWhich only works on small hobby projects, startups and a few companies of the likes of Google, Facebook and friends. On the real corporation world, it is a whole different thing. Good luck enforcing coding styles across multi-site projects, with rotating developers and off-shoring subcontractors.
- raverbashing 13y agoYes, it is hard. There are ways of putting a trigger in your source code control to enforce it, but it's not always possible. Still, projects like this have something very thorough and that goes much deeper than just tabs vs spaces: http://www.stroustrup.com/JSF-AV-rules.pdf http://www.stroustrup.com/JSF-AV-rules.pdf
- sesqu 13y agoA tab does not mean 8 spaces. That's the whole problem, people keep thinking tabs and spaces have an exchange rate. If you have a source file with only tabs (and you should, then nobody has to run an re-indent script because they can't read it), you should be inserting tabs. If you have a source file with only spaces, you should map the tab key to insert the correct amount of spaces before editing. If you have a source file with both tabs and spaces for indentation, you should re-indent.
- raverbashing 13y agoFor all purposes, yes it means 8 spaces. Type this in a bash terminal: $ printf '1234567890\n\tx\n' For the second paragraph: I couldn't agree more. There's even some "geniuses" that indent python with the 1st level being 4 spaces and the second level as a tab. * sigh *. Really.
- cocoflunchy 13y agoWhat about this? printf '1234567890\n1\tx\n12\tx\n123\tx\n1234\tx' 1234567890 1 x 12 x 123 x 1234 x Tabs are not fixed width, that's the whole point of their existence.
- raverbashing 13y agoYes, this is how it works for alignment, so you don't need spaces to align the x there This is a non issue when you have nothing to the left of the code (that is, when indenting) (and the x should be under the 9 btw)
- oftenwrong 13y agotabs for indentation, spaces for alignment
- lmm 13y agoIf there was an automated tool that could apply that I would agree with you.
- ElongatedTowel 13y agoAnd if you mix both every language that relies on indentation (Python e.g.) throws you a nice warning or even an error.
- numeromancer 13y agoSomething I wrote up a long time ago: https://docs.google.com/document/d/1HMxg6fv_yig_mVvnxsC8CwTfBJM5n5LP-_o7aXwQHAg/edit?usp=sharing https://docs.google.com/document/d/1HMxg6fv_yig_mVvnxsC8CwTf... Unfortunately I haven't had time to update the code, and it doesn't work with more recent versions of emacs. Now I'm using vim and all-spaces-all-the-time.
- sesqu 13y agoWhat breaks the alignment is editors inserting spaces instead of tabs. A tab is always the same length, but the number of spaces varies between users.
- Shorel 13y agoIndentation should be done with tabs. However, after a character that's not a tab, i.e. any printable character, spaces should be used. It is the best of both worlds, and can never be misconfigured by changing the number of spaces that a tab represents. It is also what tab advocates have been saying for years now.