Can't scroll to get the last line displayed on top, like in VS Code

Use case or problem

When I edit, I typically want to have edited lines closer to the top of the screen, no matter if I edit in the beginning or in the end. This is the matter of comfort and also a medical issue for people with neck problems (see topic Scroll past end of file).

E.g. VS Code allows this: note how I have 39 lines in my file, but I can just put the last line to the top:

Now here’s what happens when I try to do the same in Obsidian:

It does scroll past the last line, but stops at the vertical center. Why? I don’t see no reason for this except for “We just didn’t think about this”.

Proposed solution

Let it scroll one full screen last the last line, like in VS Code.

Related feature requests (optional)

Gemini or ChatGPT wrote this snippet for me a while back, you can try using it as a temporary solution, too:

@media screen {
  .workspace-leaf-content[data-type="markdown"] > .view-content > .markdown-source-view.mod-cm6 > .cm-editor > .cm-scroller,
  .workspace-leaf-content[data-type="markdown"] > .view-content > .markdown-reading-view > .markdown-preview-view {
    container-type: size;
  }

  /* 2. Live Preview and Source Mode */
  .workspace-leaf-content[data-type="markdown"] > .view-content > .markdown-source-view.mod-cm6 > .cm-editor > .cm-scroller > .cm-sizer > .cm-contentContainer > .cm-content {
    padding-bottom: calc(100cqh - -0.25em) !important;
  }

  /* 3. Reading View */
  .workspace-leaf-content[data-type="markdown"] > .view-content > .markdown-reading-view > .markdown-preview-view > .markdown-preview-sizer {
    padding-bottom: calc(100cqh - 0.5em) !important;
  }
}

You might need to tweak the values a bit (-0.25em, 0.5em) – these are set for Sandbox Vault, which is the unmodified version of Obsidian. In my main, slightly modified vault, I have the values set to 5.5 for Live Preview and Source mode, and 6.75 for Reading View.

There’s also a chance it might cause some issues in less obvious places (tables, canvases, bases, embedded notes, community plugins, …). But I haven’t noticed anything yet, although I haven’t been using tables, canvases, bases, or embedded notes lately, and I have very few community plugins.
In that case, the snippet will need to be tweaked slightly.

There are existing FR threads (which you linked to), so I’ll move this to help. Please don’t post duplicates.

I just tried that solution above and it works. The 50cqh - Nem adds an extra chunk at the bottom (I used 50cqh instead of 100cqh so it’s half the screen because Obsidian already pads half the screen dynamically based on the window height, and things like inline backlinks, etc.). And increase “Nem” to 5em or 10em if you want more of your top lines to show at the top.

The downside is that if you click in that area, your caret gets swallowed. So you might want to style it with a subtle grey background or something. Or maybe there is another CSS element that could be targeted, or maybe the existing Obsidian padding could be overwritten.

Thanks, but I have already installed a plugin Claude wrote for me.

@rigmarole This topic isn’t a request for help - I solved this problem for myself already. So please restore it as a feature request. I wonder why can’t it be a default for everybody? I consider the current behavior a poor design. The existing FR threads are slightly different or didn’t end in anything.