Whitespace/Tab issues?
Folk,
With beta1 is anyone else running into issues with PyCharm doing weird stuff with tabs/whitespace resulting in PYINDENT errors? I'm _frequently_ having to open my files in another editor and fix tabs.. they are visually aligned properly, but PyCharm seems to be using some mix of odd tabs/whitespace to align things which prevents the code from running properly.
I've futzed with the various options for Indentation settings to no avail.. what works best is "use tab characters" checked. I've tried with and without "Smart tabs" also enabled but to no avail.
User error? Editor not ready for basic functionality?
-jbl
Please sign in to leave a comment.
Hello jason,
Do you use the Tab key for setting indents? If you don't, and don't have
"Use tab characters" enabled in the indent settings, PyCharm should never
use tabs for indentation.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
The problem seems to come into play if I'm editing a file in PyCharm that's otherwise been edited beforehand with an editor that inserted spaces vs. tabs.
PyCharm is preserving the pre-existing spaces (as one would expect) and inserting Tabs as I requested.. and that appears to result in PYINDENT errors.
This likely isn't a problem seen with code written completely in PyCharm.
The inverse case may also be true: i.e., PyCharm defaults (IIRC) to not having "use tab characters" checked. Thus, opening/editing a file that was previously edited with tabs enabled (external editor) may also cause this...
A good solution would be a way to clearly identify tabs vs. spaced-indents in the UI.... If that exists already, I missed it.
(one other thought: I added a function to a class that was written in another editor that used whitespace indention at the same level as the other defines in the class. PyCharm identified that function as a 'local' function. I could only correct this by going back and removing all the whitespace indentions.)
-jbl
Hello jason,
I've filed an issue for this problem:
http://youtrack.jetbrains.net/issue/PY-1674
You're welcome to vote for it, or file additional issues if this doesn't
seem to be a complete solution for the problem.
Also note that the current version of PyCharm has a "Show Whitespaces" option
(View | Show Whitespaces) which lets you see tabs vs. whitespace differently
in the editor.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"