Python indentation error between two text-editors

Viewed 194

I have a weird problem right now in python3.

I have a script with the correct indentation, but when I compile it says I have inconsistent use of tabs or spaces.

I'm using geany, so in geany it is correct indentation, but when I open the file in vim it's all wrong. But when I fix the problem in vim it's all wrong in geany and the compiler will tell me whats wrong (in geany). So either way I'm stuck now.

Is there a way to fix this?

2 Answers

I have faced similiar problems when using notepad++ editor, When I am doing editing using notepad++ I have faced same kind of identation error.

I have replaced every tabs with 5 spaces & I am able to solve identation error in my script.

I hope doing same work for you.

Use another editor such as sublime text, VSCode or PyCharm which has a feature for replacing tabs with spaces (or the other way around), this sould fix your problem.

You can also stick with vim and run the following command inside vim:

:retab

Related