views:

315

answers:

2

Hey!

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!

+5  A: 

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.

truppo
Thanks I didn't know that :/Do you know if there is anyway to convert them fast (or do I need to go line by line)?
Joel
@Joel search and replace: \t by 4 spaces
klausbyskov
Thanks, didnt know it can find \t but with reg-exp it does :)
Joel
+3  A: 

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.

Craig McQueen
Thanks a lot!!!
Joel