Vscode: Feature Request: Scroll Off

Created on 14 Sep 2016  路  15Comments  路  Source: microsoft/vscode

In Vim, you can set a scrolloff so it keeps at least N lines below the cursor:

scrolloff

Currently Code has a scrolloff of 1. Would be great if this is made an option.

editor-rendering feature-request on-testplan

Most helpful comment

You should be able to set editor.scrollOff later this week with Insiders.

All 15 comments

Does VS Code have a "scroll window leaving cursor in view" command? The scroll commands I see in the default keymapping all scroll the cursor out of view.

The answer to my question is yes - editorScroll function can do this, but behavior is a little different than vim behavior shown in the animated GIF. I believe request is for scrollLineDown but maintain the cursor position.

I believe request is for scrollLineDown but maintain the cursor position.

Not exactly. The feature is to scroll sooner, to always show context lines around the cursor. Currently, when moving down, scrolling ensures 1 context line left below the current line, and when moving up, none at all (scrolling does not begin until the cursor hits the top of the panel).

It is very comfortable to always keep 4 or 5 visible lines above/below the current line, after all moves that move it (next search hit, go to matching parenthesis, etc.).

This feature is called scrolloff in Vim and scroll-margin in Emacs.

There is an extension vscode-scrolloff that provides similar functionality.

I've removed Vim label since I see Sublime also have it.
Although @semanser's extension works well, I still hope this can make it into the editor itself since it's a common feature.

soff

So is this being considered at all? Really missing this and the extension for that misbehaves with the vim plugin.

There is an extension vscode-scrolloff that provides similar functionality.

That extension misbehaves badly when your have lines longer than your working window.

The extension also doesn't work with the Vim extension's zb / zt commands.

Come on, we need this common feature

You should be able to set editor.scrollOff later this week with Insiders.

Considering that this feature in VS Code is slightly different from Vim's scrollOff (for example, you can scroll the viewport without moving the cursor in VS Code, which is not affected by this feature), it's being named as editor.cursorSurroundingLines.

It's being named as editor.cursorSurroundingLines.

How does this interact with editor.scrollBeyondLastLine, if at all? I have considered requesting a change to the latter to support numeric values in addition to boolean ones (which is actually how I came across this issue), and this new setting seems to partially address the reason why I'd want that: to prevent meaningful context to be scrolled entirely out of view.

@waldyrious it's a different feature request https://github.com/microsoft/vscode/issues/56174

Thanks for the pointer, @rebornix. I've subscribed to that issue.

@rebornix Thanks for implementing this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

borekb picture borekb  路  3Comments

curtw picture curtw  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

ryan-wong picture ryan-wong  路  3Comments