Indentation within class

I have noticed when I run pycharm's code reformatter in a module indentation looks like this: (I have used '.' to highlight spaces)

class A(object):

....def __init__(self):

........pass

....def func(object);

........pass

Is it possible to change this behaviour to the following?

class A(object):

....def __init__(self):

........pass

....

....def func(object);

........pass

# Indentation is maintained in the whitespace between class methods

This would make it convenient if I need to paste code into a python interpreter to quickly check something.

Thanks.

4 comments
Comment actions Permalink

Have you tried this setting in Settings | Editor?



Attachment(s):
keep_trailing_whitespace.png
0
Comment actions Permalink

Also try:  From the menu choose Help -> Help Topics enter "white space" in Find and pick Editor Apperance (and others)

-PL

0
Comment actions Permalink

Even if you choose not to strip trailing space on save, everytime you use the reformat code command it still strips all the spaces from within classes. I'd like a fix for this too, its cosmetic but I find it annoying since it forces you to keep adding indents whenever you are trying to fill in new lines in a block. Pycharm shouldn't be automatically fucking around with the indents within a block.

0
Comment actions Permalink

I see this behaviour is still (annoyingly) present in the latest build, 1.2.1 

I've gotten very used to selecting a block of code from a text editor or web browser and pasting it into a running python interpreter. With pycharm mangling the spaces within a block, this will instead generate a bevy of SyntaxErrors.

Please provide some way of controlling this indentation stripping behaviour during reformat in the settings, as the "Strip trailing spaces on save" option is misleading (unchecking it will only have the desired effect if the user never reformats their code). Surely I can't be the only person who is irked by this.

0

Please sign in to leave a comment.