filetype plugin indent on
autocmd! FileType yaml setlocal autoindent smartindent expandtab sw=2 ts=2 sts=2
|
is cursor)key: val
|
The cursor maintains the correct level of indentation.
key: val
|
PR #10328 describes this exact behavior, which was closed in favor of commit f4f579b. This was back in 2022. However, I've experienced this behavior for many years... I only just now decided to try and get to the bottom of it.
9.1.016
OS: Fedora 39
Terminal: GNOME Terminal 3.50.1
$TERM: xterm-256color
This is a completely clean installation of F39. I also see the same behavior in Debian 12, openSUSE Tumbleweed, etc
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Found it! Reverting the file back to v9.0.0380 fixes the issue.
0daafaa#diff-723cc09b2d0f8f9383c670a8846979363fbc67a741aad1aae657242b8c2667a3L57
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Reverting the diff is definitly wrong. The diff from v9.0.0379
fixes a syntax error. Try and search for it, you will get the following error: /\v%(%\x\x)
: E678: Invalid character after %[dxouU]
.
Guessing from the yaml.vim indent script, where it goes wrong it is this one here:
https://github.com/vim/vim/blob/02d7a6c6cfceb3faf9c98fcb7c458760cd50d269/runtime/indent/yaml.vim#L145-L151
As mentioned in the comment below, this is trying to match the following item:
Mapping with: value
that is multiline scalar
which is what is happening in your case (and seems to be correct).
I think this is intentionally, and once you type :
the cursor position will jump back to the beginning of the line. So I think the current behaviour is right.
So it seems there is just a misunderstanding about whether or not the yaml.vim
indent script should try to match a multiline scalar or whether it shouldn't. But given the work-around, that :
dedents the line again, I would think the current behaviour is okay just perhaps a bit unexpected.
Having said all that, I haven't heard from @ZyX-I in a long time. So if anybody wants to volunteer to maintain this, please stand up :)
But be warned, that are some crazy Vim regexes here.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Closed #13845 as not planned.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I want to disable that smart multiline indentation. I want my cursor to be on the same level as previous line. It is driving me crazy.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
remove those two lines from your copy then
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Frightening regexes for sure! My two cents is that writing multiline scalars is less common than writing consecutive key-value pairs, so it seems odd to indent for them as the default behavior.
Either way, good to know what exactly is going on behind the scenes and which lines to modify.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Reopened #13845.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Let me add a configure switch for people to opt-in into the multiline detection and include it.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Hey, thanks! I'll also note that I ended up commenting starting from line 141 since that does the same multiline scalar assumption for list items.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Closed #13845 as completed via b4eb3f1.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.