Reputation: 673
I have been using NotePAD++ for editing Python scripts. I recently downloaded the PyDEV IDE (for Eclipse). The problem is that when I wrote the scripts in NotePad++ I used "TAB" for indentation, and now when I open them with PyDEV, every time I try to write a new line instead of "TABS" PyDEV inserts spaces. (even if I click the "TAB" key Eclipse inserts 4 spaces instead of one tab). This raises indentation error.
Is there anyway to fix this thing?
Thanks!
Upvotes: 4
Views: 9751
Reputation: 41
Putting aside the tabs vs spaces argument.
To fix this you need to chose 'toggle force tabs' in preferences for eclipse to use tabs instead of the default spaces.
Upvotes: 3
Reputation: 43456
Tabs are problematic—different people can choose different widths in their editor settings, and then you have bad formatting (for e.g. C) or execution problems (Python). So spaces are better for getting consistently sensible results. But one issue with that is that some editors still default to using tabs.
In the companies I've worked for, our coding guidelines have specified that we should always use spaces, no tabs. But default editor settings sometimes catch us out.
In Eclipse with PyDev, the fast way to convert tabs to spaces is the menu item Source⇒Convert tabs to space-tabs.
Upvotes: 4
Reputation: 27305
Yes, follow http://www.python.org/dev/peps/pep-0008/ which states:
Indentation
Use 4 spaces per indentation level.
Replace all your tabs with spaces, and set Notepad++ to use spaces instead of tabs.
Setting Eclipse to use tabs instead of spaces would be a step in the wrong direction.
Upvotes: 7