-
In the Sublime kemap, there's a shortcut to scroll the focused line to the middle of the editor window via the Does anyone know if it's possible to scroll a line to the top of the window in a similar way? I've searched the CodeMirror forums, and for developers embedding CodeMirror, there are lots of suggestions to add this functionality to a CodeMirror instance, but as a Stylus user and not code contributor, I'm not sure how I'd pull that off. I've tried fiddling around with JavaScript in my browser's dev tools, but Stylus is more complicated than most CodeMirror editors, especially thanks to its many code sections. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The workaround for the current editing session would be to run the following code in devtools: CodeMirror.commands.showCurLineAtTop = cm => cm.scrollTo(null, cm.cursorCoords(null, 'local').top);
CodeMirror.defaults.extraKeys['Alt-T'] = 'showCurLineAtTop'; Alt is physically the Opt key in Mac. Note that ⌘T can't be used in a shortcut as it's a built-in browser key, unless you also use navigator.keyboard.lock(), but that's not supported in Firefox/Safari, which is why we don't use it in general. I think this is trivial and possibly useful enough for me to include the command in Stylus, but I'd like to check those suggestions you mentioned first as there may be some useful nuance. If you want to patch Stylus and use it as an unpacked extension, add the above code to codemirror-default.js. |
Beta Was this translation helpful? Give feedback.
The workaround for the current editing session would be to run the following code in devtools:
Alt is physically the Opt key in Mac. Note that ⌘T can't be used in a shortcut as it's a built-in browser key, unless you also use navigator.keyboard.lock(), but that's not supported in Firefox/Safari, which is why we don't use it in general.
I think this is trivial and possibly useful enough for me to include the command in Stylus, but I'd like to check those suggestions you mentioned first as there may be some useful nuance. If you wan…