28

Tabs or spaces?

A script that replaces <your project's style> with <your preference> whenever you pull and does the opposite just before committing.

Spread code not war

Comments
  • 4
    git has some filter features to change tabs to spaces and the other way round
  • 3
    Use Prettier.
  • 2
    Just helping myself with this opportunity to rant about vimming hotfixes on a python server via ssh and using tab without even realizing it which causes it to fail to launch because of mixed tab/indent error.

    I get it, it's my fault and python enforces spaces to encourage standardized practices, but goodness it's such a perfect storm of the most trivial cause of "build" error and when I need it the least.

    At least now I've learned you can search/replace tabs pretty easily in vim. Before that I was just navigating around trying to find it with the caret, trying to fix it before anyone noticed the server was down. Expert developer here.
  • 1
    The projects style is the preferred. Nobody needs unnecessary reformatting and conversions of parts that you haven't touched, especially not ten times a day on pull and push. It will eventually not change 100% back and forth without changes and nobody needs diffs with changes that did not really happen.
  • 1
    @rithvikp Or set up your editor to respect the project's style and stop caring about it.

    The EditorConfig project (https://editorconfig.org/) is a good way of having everyone on the team on the same page.
  • 0
    Python doesn't enforce spaces. It doesn't allow you to mix tabs and spaces. If you use tabs, the whole file has to be tabs.
  • 0
    @ddephor I only agree partially with you. You should respect the project style because that's important in keeping the code consistent, but if you are working on multiple projects or especially multiple organizations (maybe one for work, the other for fun?), readability takes a hit. Switching between reading code indented at depth 8 (Linux) to a project using depth 2 (ippsample) was a nightmare for me.
  • 0
    @ethernetzero Applies when I am writing code but not so well while reading code (which is what I am doing most of time these days as an entry level dev :))
  • 2
    But why? Any decent IDE will convert your indentation to whatever you set up.
  • 0
    @ethernetzero +1 for EditorConfig though, it sounds like a great util. I should try it sometime
Add Comment