Replit Randomly sets all tab indententations to double spaces despite preferences

Problem description:
Replit will randomly switch all of my tab indentation to double space when working with python, despite my preferences clearly saying that I am set to tab mode. Then, I have to go to find and replace and manually replace all instances of double spaces with tabs, as python doesn’t work with mixed spaces and tabs.

Expected behavior:
I would expect that, when my setting is set to “tabs” that replit would respect that and keep all my tab indentation.

Actual behavior:
Replit formats my code to use double spaces instead of tabs at seemingly random intervals.

Steps to reproduce:
write python code with tab format with “tabs” setting enabled
Replit randomly formats code to use double space indentation, causing errors

Bug appears at this link:

Browser: Firefox 116.0.3
OS: Windows 10 Home
Device (Android, iOS, n/a leave blank):
Plan (Free, Hacker, Pro Plan): Free

Hi @NathanRJ , welcome to the forums!
Could you send a screen recording of the issue?

This problem seems to occur whenever the automatic formatting function is used. I’m trying to get a recording but am having issues with this error now. I will send a recording after I get it working properly
image

Can you press SHIFT+CTRL+R when in the page? This will refresh the cache of the page.

Here’s a screen recording of the bug occurring. Small correction, it is actually 4 space indentation that it gets switched to. The issue with failed formatting was due to a syntax error.

Try having the find tool replace all instances of 4 spaces with \t (tab), make sure it’s on Regex mode though.

1 Like

Welcome to Ask! I tested this. What I found was that if I had my indents set to tabs and used Ctrl + S to format my code (note that it only makes it prettier and does not save it as Replit saves automatically) it will replace all the tabs with two spaces (I have indent set to two spaces in my settings). I can see how this would be a problem for running your Python code.

Replit was having other issues with tabs and spaces recently as well (similar, but not the same).

2 Likes

Others: migrate to Nix modules to get this behaviour.
Use my fork of the lsp → ruff for a repl which also respects your indent type preference.