I’ll try to give a short step by step to get it to work.
Note that you don’t even have to restart Sublime Text, as soon as you save the files it should work.
On windows, go to:
%appdata%\Sublime Text 3\Packages\User
which is the equivalent of:
C:\Users\MYUSERNAME\AppData\Roaming\Sublime Text 3\Packages\User
In this folder, create a file called: scroll_lines_fixed.py
(I think the filename needs to match the class command name inside the file, but not 100% sure)
Just to be clear, you end up with this file:
C:\Users\MYUSERNAME\AppData\Roaming\Sublime Text 3\Packages\User\scroll_lines_fixed.py
Edit the file, paste the code mentioned below (1) in it.
Save the file.
(1) The code which starts with import sublime
… class ScrollLinesFixedCommand
… etc. ,
as found in this post (should show in view if you click this link): ST2: How to Page Up/Down without moving the cursor )
By itself, the above does nothing yet, we still need to assign keyboard shortcuts that use it.
Open your key bindings : Sublime Text 2 -> Preferences -> Key Bindings
On the left hand you see all default keybindings, on the right you can add your own keybindings that
override those defaults.
On the right, copy paste this:
[
{ "keys": ["pageup"] , "command": "scroll_lines_fixed", "args" : {"by": "pages", "amount": 1.0 } },
{ "keys": ["pagedown"], "command": "scroll_lines_fixed", "args" : {"by": "pages", "amount": -1.0 } },
]
(note that the above overrides the default behaviour of pageup and pagedown)
As soon as you save both files, it should work. No need to reload Sublime Text.
In my keybinds suggested earlier I set up a theme where normal keys (as default) move the cursor,
and when I hold down alt, instead it moves the viewport without moving the cursor.
(using up/down/left/right/pgup/pgdown/home/end with or without alt)
I’ll repeat those key bindings below:
[
{ "keys": ["alt+up"] , "command": "scroll_lines_fixed", "args": {"amount": 1.0 } },
{ "keys": ["alt+down"] , "command": "scroll_lines_fixed", "args": {"amount": -1.0 } },
{ "keys": ["alt+pageup"] , "command": "scroll_lines_fixed", "args" : {"by": "pages", "amount": 1.0 } },
{ "keys": ["alt+pagedown"] , "command": "scroll_lines_fixed", "args" : {"by": "pages", "amount": -1.0 } },
{ "keys": ["alt+home"] , "command": "scroll_lines_fixed", "args" : {"to": "top" } },
{ "keys": ["alt+end"] , "command": "scroll_lines_fixed", "args" : {"to": "bottom" } },
{ "keys": ["alt+left"] , "command": "scroll_lines_fixed", "args" : {"to": "left", "amount": 10.0 } },
{ "keys": ["alt+right"] , "command": "scroll_lines_fixed", "args" : {"to": "right", "amount": 10.0 } },
{ "keys": ["alt+keypad_enter"], "command": "scroll_lines_fixed", "args" : {"to": "cursor" } },
// { "keys": ["alt+keypad5"] , "command": "show_at_center" }, // only works with numlock on
{ "keys": ["clear"] , "command": "show_at_center" }, // clear is keypad5 without numlock
{ "keys": ["alt+clear"] , "command": "show_at_center" },
]
I think you have all the information now to make it work however you prefer