language-python
language-python copied to clipboard
Auto indent on line continuation with list/tuple
Pressing enter after continuing a list or tuple on a second line. It should either auto indent one tab, or to the first char of the previous item, but it just goes to the beginning of the line. Manually pressing auto indent (Lines->Auto Indent, or cmd+i), doesn't do anything.
should be either
somefunc(bar,
m)
or
somefunc(bar,
m)
I vote for:
f = function(foo,
bar)
Actually, that is not a good example since it's not recommended in PEP8:
# Shouldn't be used:
# Arguments on first line forbidden when not using vertical alignment.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Further indentation required as indentation is not distinguishable.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
But, for the recommended ones, this change would help:
# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# More indentation included to distinguish this from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# Hanging indents should add a level.
foo = long_function_name(
var_one, var_two,
var_three, var_four)
+1 for this and I also vote for following the PEP8 guidelines. The following indentation is usually what other editors use:
# More indentation included to distinguish this from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
+1
My vote is for these two:
# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
# More indentation included to distinguish this from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
+1
+1
I was this close to replacing Emacs with Atom but I cannot use an editor that doesn't get autoindent right.
PEP8 compliance is obviously the only right choice, anything else would be unacceptable. Where PEP8 allows leeway, just do the base case:
[1, 2, 3
4, 5, 6]
[
1, 2, 3
4, 5, 6
]
:+1:
+1
+1, was trying out Atom today, wouldn't use it unless this was supported. Too used to Vim/PyCharm doing this for me.
Is there any work that would need to be done in order to make it happen? If its something someone unfamiliar with the project can do, I might be interested.
+1
Is there a third-party package that implements this behavior since it's not in core yet?
So with Atom 1.0, this issue is still definitely legitimate. However, it looks like hitting tab at least allows you to manually indent the line, which is a passable bridge until it works properly. Auto-indent will completely remove any manual indentation, however, which seems like something that should be fixed.
+1 for following pep8 guidelines by default. jupyter notebook does it by default and it feels like an instant reward whenever I use it. I would love atom behaving the same.
@mattdeboard I'm not sure what you mean -- I've upgraded to 1.0 but I haven't noticed any difference with what my tab key does. It still just always either indents 4 spaces, or indents to the previous line's level.
It's really painful to match up indentation to PEP8 style, especially since atom makes it very difficult to indent to levels indivisible by the tabstop. I often find myself deleting an "indent" (4 spaces) and then spamming my spacebar to get my code to line up properly. :sob:
@radix Pre-1.0, when you hit enter after an open-paren (or any sequence literal), the cursor would start at the beginning of the next line, instead of indented by one level. Hitting <Tab>
would not move the cursor.
Now, the cursor still starts at the beginning of the next line, but tab moves the cursor. This is good-enough behavior, I think. Especially since it appears this is the same behavior as in SublimeText (and presumably TextMate, but I didn't check).
FWIW that pain you have adhering to PEP 8 is because, IMO, only regex is being used to define indentation behavior.
+1 voting for this, this is the reason I prefer pycharm over atom for python file editing.
This is NOT the same behavior as in SublimeText, there I get PEP8 correct indenting of function parameter lists that become too long to fit on one line. Without this, I cannot use Atom, alas. :(
+1
yep this is very annoying. Atom has so much potential..alas if basic code indentation doesn't work then I would be able to continue using atom.
For one that is new to atom and its packages, is this a python package specific problem or an atom problem?
Part of it is this package (missing a lot of regex rules) and part is atom (no way to define dynamic indentation rules required by PEP8).
+1 ... come on ...
+1 dear god this is ****ing ridiculous. How is this not a thing. Why even have support for pep8 linters if you can't ACTUALLY support pep8?
Can we get an update from a maintainer? This bug/defect has been around for a very long time, and clearly there are many people who are interested in having this fixed. What would it take to fix this? I haven't contributed to Atom before, but am willing give it a try if thats what it takes for this to move to in progress.
What would it take to fix this?
The current auto-indentation rules are regex based, which makes matching these types of scenarios very hard.
It's also worth mentioning that TextMate, upon which Atom's language mode is based, doesn't get this right either (last I checked anyway).
python-mode for emacs does.
How do editors that do this correctly accomplish it? Some method that is not regex based?