Sublime Forum

Faster arrow key speed? keyboard scrolling

#1

There’s a setting to change the mouse scrolling speed, how can I change the arrow key scroll speed though? ctrl+down/up and normal up/down are useful as they are, but say I want a modifier like alt+down/up to make the arrow scrolling 4x faster. Might be ideal to have some kind of exponential speed for this as well so when you hold down for longer it goes faster and faster which is ideal if u have a ways to scroll, but that’s not as important right now.

Right now I have it setup so alt+up/down is pageUp/down but that’s not the same thing. Like say I want to travel from the bottom to a custom zone near the top of my screen without shifting the screen…i have to just wait for the up/down arrow keys to sloooowly get there. I’m trying to stop using the mouse as much cause I’m finding it slows me more than the keyboard does.

0 Likes

#2

OS sends repeated events for hold down keys with certain frequency, which limits caret movement speed and thus viewport movement speed.

A possible way might be to bind keys to a command, which move caret by multiple lines at a time to gain more speed.

travel from the bottom to a custom zone near the top of my screen without shifting the screen

What does without shifting the screen mean?

0 Likes

#3

It means without shifting the viewport, so whatever code is onscreen is not shifted offscreen.

I’m just going to use this: Move cursor to top/middle/bottom of visible lines
so it jumps 5 lines up/down when u alt+left/right, and rebind page-up/page-down to alt+up/down. The main problem though is it moves the entire screen 50% up/down when it goes above the current viewport’s display. I’d rather it do the normal behaviour of the arrow keys when u go past the viewport and just keep the current line as the top.

It’s this part of the plug-in, where when binded will let you jump nlines up your screen. But when it gets to the top of the screen and goes n-lines offscreen it recenters your screen with the current location via the last line it seems. I can’t figureout how to modify it so it behaves like normal arrow keys do when u go offscreen.

class Move_caret_backCommand(sublime_plugin.TextCommand):
    def run(self, edit, nlines):
        screenful = self.view.visible_region()

        (row,col) = self.view.rowcol(self.view.sel()[0].begin())
        target = self.view.text_point(row-nlines, col) #how far up the cursor moves

        self.view.sel().clear() #prevents multi cursors
        self.view.sel().add(sublime.Region(target))
    
        self.view.show(target)
0 Likes

#4

view.show() will always center target if it was off-screen before. To keep ST’s default viewport scrolling behavior including context_lines, just chain normal move command.

	{
		"keys": ["alt+up"],
		"command": "chain",
		"args": {
			"commands": [
				{"command": "move", "args": {"by": "lines", "forward": false} },
				{"command": "move", "args": {"by": "lines", "forward": false} },
				{"command": "move", "args": {"by": "lines", "forward": false} },
				{"command": "move", "args": {"by": "lines", "forward": false} },
				{"command": "move", "args": {"by": "lines", "forward": false} },
			]
		},
	},
	{
		"keys": ["alt+down"],
		"command": "chain",
		"args": {
			"commands": [
				{"command": "move", "args": {"by": "lines", "forward": true} },
				{"command": "move", "args": {"by": "lines", "forward": true} },
				{"command": "move", "args": {"by": "lines", "forward": true} },
				{"command": "move", "args": {"by": "lines", "forward": true} },
				{"command": "move", "args": {"by": "lines", "forward": true} },
			]
		},
	},
2 Likes