Legonaftik
Legonaftik

Reputation: 1390

How to change tab size in a specific file in Pycharm

I know that I can change tab size in general using Settings -> Code Style -> Python -> Tab size

But what if I was given a file with tab size 2 and want to change it to 4. Is there a fast way to do it?

Upvotes: 10

Views: 17183

Answers (2)

Natacha
Natacha

Reputation: 1250

FWIW: After I reformatted the 2-spaced file entirely, my PyCharm kept behaving like 2-spaced...which of course broke the code every time I hit enter.

Solved it clicking '*2 spaces' in the status bar, at the bottom of the code window. That opens a menu with several options, even a link to the settings. In that menu just choose "4 spaces" and PyCharm is gonna start behaving like usual python (4-4-8).

Upvotes: 1

Sam van Kampen
Sam van Kampen

Reputation: 1013

If you want to change the tab size, first set the tab size you want in Settings -> Editor -> Code Style -> Python -> Tab size, then re-indent the code you want by selecting it and pressing Ctrl-Alt-L.

If you want to change the tab size in just one file, you could use Ctrl-R (find and replace) and replace two spaces by four (or vice versa).

Source: PyCharm documentation - Changing Indentation

Upvotes: 13

Related Questions