-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird indentation for nesting mappings (dicts) and sequences (lists) #80
Comments
Hey @waylan, I got what you mean. This behavior is intended, so this is not a bug. I think the problem lies in what you said at the end: I realize the documentation acknowledges that "some people perceive the I can agree the perception of this is quite subjective, but I'll try to explain why most people start counting indentation after the ---
items:
- Item 1: item-1
- Item 2:
- - Item 2.1.1
- Item 2.1.2
- Item 2.1.3
- - Item 2.2.1
- Item 2.2.2
- Item 2.2.3
- Item 3:
- this
is a
multiline string
- key-a: A
key-b: B
key-c: C If we took your way of indenting, it would have given this: ---
items:
- Item 1: item-1
- Item 2:
- - Item 2.1.1
- Item 2.1.2
- Item 2.1.3
- - Item 2.2.1
- Item 2.2.2
- Item 2.2.3
- Item 3:
- this
is a
multiline string
- key-a: A
key-b: B
key-c: C ... which is not the same structure (it is actually not even valid YAML). I hope this helps, let me know if I wasn't clear! |
First, while I understand how it works, I hate that indentation convention (I know many people use that for Markdown lists, which I also hate), I want to hit the tab key once for each level of indent and that's it. As it is now, I would need to type 2 tabs & 2 spaces for the second level of indent and 4 tabs for the third level of indent. The fact that every other level switches between a half-tab and a full tab is even more annoying. In fact, the documentation suggests that the options are there for those who don't want that behavior (specifically it says: "when in a mapping, this indentation is not mandatory"). Yet, I can't get anything but that behavior, so something is broken. At the very least To be clear, for multiple-line text fields, I understand it (even if I don't like it). For everything else that should not be how it works, IMO. If others disagree, fine, but please give me the option to do it my way. |
As a compromise I would be okay with this
Here, the secondary lines of a text block are indented the extra two spaces to account for the |
100% agree. Almost 4 years later, this still keeps me from using yamllint. Every YML checker in the worlds says this is perfectly valid YML, except for yamllint: foo:
- bar:
- baz |
I have the following sample (indentation represented by the middle-dot for demonstration purposes only) which by my eye is indented in the only sensible way:
Yes, I get the following output which makes no sense:
I've tried changing the
indentation
rules in various ways but never seem to get a reasonable result. Settingindent-sequences
to any oftrue
,whatever
orconsistent
all result in the same output (yes, evenwhatever
! What's up with that?!). Settingindent-sequences
tofalse
gives this:... which still makes no sense. Actually, with
indent-sequences: false
you need to keep making changes until none of the lines are indented at all. Therefore, the above output is rather misleading.In either case, why would the suggested indent be anything but a divisible of the
spaces
value (4
in this instance, although the same behavior presents itself with other values includingconsistent
).Going back to the
default
, you end up with this following to pass (again with indentation represented by the middle-dot for demonstration purposes):The first level of indent is
4
spaces, but all subsequent levels of indent are6
spaces. I realize the documentation acknowledges that "some people perceive the-
as part of the indentation", but I don't see how that fits here. Especially as you can't actually override it, which is the rational given in the documentation for providing the overrides.I don't really care about the rational, I just want to enforce consistent (4 spaces for each level) in my YAML files and the current set of options don't allow that. If the current behavior was intentional, then an additional option need sot be provided. If the current behavior is a bug, I'm willing to take a crack at a fix. So is this a bug or not?
The text was updated successfully, but these errors were encountered: