Sublime Forum

scroll_lines command move also the caret

#1

When moving the viewing area using scroll_lines command, the caret must not move.

When you have only one caret, the caret follow the viewing area.
when you selection is not empty or do you have more than one caret, the selection(s)/caret doesn’t move.

{ "keys": "ctrl+up"], "command": "scroll_lines", "args": {"amount": 1.0 } }, { "keys": "ctrl+down"], "command": "scroll_lines", "args": {"amount": -1.0 } }
startup, version: 2219 windows x64 channel: nightly

0 Likes

[RESOLVED] How to scroll the document with the keyboard?
#2

Looks like it’s not a bug.
Comparing with others editors, some have the same behavior as ST2, some works as I expected (Eclipse).

I wrote my own plugin to make ST2 works like I want, I post it if someone is interested:

[code]import sublime, sublime_plugin

class ScrollLinesFixedCommand(sublime_plugin.TextCommand):
“”“Must work exactly as builtin scroll_lines command, but without moving the cursor when it goes out of the visible area.”""
def run(self, edit, amount):
maxy = self.view.layout_extent()[1] - self.view.line_height()
curx, cury = self.view.viewport_position()
nexty = min(max(cury - self.view.line_height() * amount, 0), maxy)
self.view.set_viewport_position((curx, nexty))[/code]

//scroll_lines fix { "keys": "ctrl+up"], "command": "scroll_lines_fixed", "args": {"amount": 1.0 } }, { "keys": "ctrl+down"], "command": "scroll_lines_fixed", "args": {"amount": -1.0 } }

1 Like