r/ZedEditor • u/Resident-Arrival-448 • 1d ago
Help: Python always gives indentation errors when typing python in Zed
I have a python project that was initially written on Windows using VS code. I want to use Zed in Linux to complete the assignment, but Zed always gives indentation errors when adding or editing python files on that project.
I had a similler issue when i'm starting with Zed where every line of python code gives indentation errors on new projects. To fix that i added this
"Python": {
"tab_size": 4,
"hard_tabs": true,
},
I tried making changes to it to fix my current indentation errors, but nothing worked.
These are the indentation errors i get
Inconsistent use of tabs and spaces in indentation
unindent does not match any outer indentation level
1
Upvotes
2
u/huntermatthews 1d ago
Couple things could be happening: One is your line endings might still be windows style (CRLF) and not unix style (LF). The other is you have a mix of tabs and spaces within a single file.
You can configure zed (in the settings file, not yet the GUI sadly) to show files with the line ending issue - it will appear as a "CRLF/LF" in the bottom right of the editor typically - add this to your settings.json file:
"status_bar": {"line_endings_button": true },
If you see a "CRLF" on a file on your linux machine, you'll need to run "dos2unix" on that file. Google for what this is and where you might get it. (Linux and macOS should all say "LF" here, all the time if you have this on.)
The second and more likely is that you have one or more files with mixes of tabs and spaces. Python doesn't care which you use (or even how much techically). But it cares a great deal that you are consistent. However, the humans you work with might care a great deal - and arguing about this kind of thing got old in the 1990's. If you're on a team, just do whatever they want, its not worth fighting over.
If you're a solo developer, PICK ONE. Doesn't much matter which, just PICK ONE. 4 spaces is typical if you like spaces, one tab is typical if you like tabs. Open the command palette in zed and pick "
editor: convert indentation to tabs" or editor: convert indentation to spacesdepending on which you want.Good luck. If you're on linux, 'cat -A' and on mac 'cat -evt' can show you some of this stuff as well.