I'm on OS X 10.8.4 using ST2. When I use the Home and End keys, the viewport moves and the cursor is left alone. This is standard Mac behavior, and what I'd expect.
However, when I use Page Up (pageup/pgup) and Page Down (pagedown/pgdn), the cursor moves along with the viewport. This is not how other Mac apps behave, and I'd like the cursor to be left alone for these keys too.
I've been able to get this half-working by adding this to my key bindings:
[
{ "keys": ["pageup"], "command": "scroll_lines", "args" : {"amount": 30.0} },
{ "keys": ["pagedown"], "command": "scroll_lines", "args" : {"amount": -30.0} }
]
However, the amounts there are hard-coded. It looks like viewport_extent will get me the height of the viewport, but how can I use that from within the key bindings file? Is this even the correct solution for this? I feel like it's an awful lot of work to go to to get this behavior.
Thanks in advance.
Just using
Fn+up
to pageup andFn+down
to pagedown.Just my 2¢, but I have mine setup to scroll up or down with the following:
I use a Mac, so the "super" key is the command key, which is the first key to the left (or right) of the space bar. Not sure what the equivalent would be on Windoze; perhaps it would be the "Start" key or something. Anyway, works like a charm.
To do this requires a text plugin. Thanks to user bizoo on the ST Forums, you don't have to write this yourself:
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=12793
This works exactly as I'd expect.
Sublime Text 3 Update: You can follow the instructions below, with the minor change that the file should end with
.py
(e.g.scroll_lines_fixed.py
) and should be loose in the~/Library/Application Support/Sublime Text 3/Packages/User/
folder.Sublime Text 2 Update: This isn't clear, and also uses a bare URL which could conceivably die in the future. So here's a more complete explanation of what you need to do.
Add these four lines to Sublime Text 2 > Preferences > Key Bindings - User, inside any square brackets that are already in the file:
Replace the contents of the new file with this: