Option to align multiple assignments
See original GitHub issueOften the following convention is used:
a = 1
bb = 2
ccc = 3
whilst this is against pep8, it seems like this would be a nice option to support for those people that are (forced??) to use this convention.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:35
- Comments:19 (4 by maintainers)
Top Results From Across the Web
How to align several assignments in vim - Stack Overflow
I use Align and I think it does the job: Whole file: :Align = Visual line: <leader>t= or :'<,'>Align = (i.e. : from...
Read more >Align or arrange objects - Microsoft Support
Align multiple objects. Select the objects you want to align. Click the first object, and then press and hold Ctrl while you click...
Read more >3 Tips to Increase Alignment when Managing Multiple Projects
Are you having alignment and visibility troubles in your multi-project paradise? Read about 3 common mistakes project managers do and how to ...
Read more >Align Your Code With Align Assignments Visual Studio ...
To align assignment select all the lines which you want to align and press Ctrl+Alt+] and all the assignment will be aligned properly...
Read more >Code Style: Align Consecutive Assignments?
At the bottom of this article, you see the feature "Align Consecutive Assignments". I'd like to do the same in AppCode, but I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
“After 5 years, this is still an open issue…” – yapf is Open Source, and no doubt a contribution would be accepted.
In case this does ever get worked on (even if by me), I’ll add some more notes…
It would be nice to go further and preserve alignment for more than just equals signs. Maybe an option along the lines of this:
PRESERVE_VERTICALLY_ALIGNED_SYMBOLS = true
When enabled, yapf could try and detect and preserve alignments such as this:
However, this could get confusing/complex if different symbols are used (
+
vs-
), or with commented lines (which I think should be ignored in a contiguous line block), or alternative object constructs…My opinion on that example block is that it would still be be untouched with the alignment feature enabled. Reasons being: A) the commented line should be ignored from an alignment perspective (could be a pure comment); B) the the
+
and-
could be recognized as symbols for alignment, and; C) the nested(yyy + 9)
doesn’t have symbols that consistently align across the block so aren’t part of any alignment consideration.Additional notes/ideas:
=
,+=
,|=
,>>=
, etc… but not delimiters used for literal definitions (all bracket forms,:
,.
, etc)(x+1)
to(x + 1)
would alter alignment, so any alignment detection (and any stashing of in-line alignment positions) would have to be determined in advance.=
would be great, with possible expansion to aligning other tokens left as a future option/pipe-dream.# yapf: enable/disable
works well enough for now