Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scrollz

Viewport control for the micro editor. Put the line you are reading where you want it on screen, and move half a screen at a time without losing your cursor.

The companion to navz, which does the same job for VS Code.

What it does

Command Effect
scrollz top Scroll the cursor's line to the top of the view
scrollz bottom Scroll the cursor's line to the bottom of the view
scrollz center Scroll the cursor's line to the center of the view
scrollz halfdown Move down half a screen, cursor comes along, recentered
scrollz halfup Move up half a screen, cursor comes along, recentered

The first three move the view only — your cursor does not budge. The last two are vim's Ctrl-D / Ctrl-U: cursor and view move together, cursor lands centered.

Why not just use micro's built-ins

micro ships Center (which scrollz center simply wraps) but has no equivalent of vim's zt or zb — its CursorToViewTop / CursorToViewBottom do the opposite, moving the cursor rather than the view.

It also ships HalfPageUp / HalfPageDown, but those scroll the view and leave the cursor where it was. As soon as you move the cursor, micro relocates the view back and the scroll is undone. scrollz halfup / halfdown move the cursor as well, so the jump actually sticks.

Install

Via micro's plugin manager

Add this repo to pluginrepos in ~/.config/micro/settings.json:

"pluginrepos": ["https://raw.githubusercontent.com/vish9812/micro-scrollz/main/repo.json"]

Then:

> plugin install scrollz

Manually

git clone https://github.com/vish9812/micro-scrollz ~/.config/micro/plug/scrollz

Either way, restart micro. Verify with > help scrollz.

Keybindings

scrollz binds nothing by default. Add to ~/.config/micro/bindings.json:

{
    "Alt-d": "lua:scrollz.halfDown",
    "Alt-u": "lua:scrollz.halfUp",
    "<Alt-z><t>": "lua:scrollz.top",
    "<Alt-z><b>": "lua:scrollz.bottom",
    "<Alt-z><z>": "Center"
}

None of these overwrite a micro default. Ctrl-D and Ctrl-U are already Duplicate and ToggleMacro, so the half-page pair lives on Alt. The Alt-z prefix mirrors vim's z namespace and keeps room for more view commands later.

Softwrap

All movement counts display rows rather than buffer lines, so with softwrap enabled half a screen means half of what you can actually see. scrollmargin is respected by top and bottom; set it to 0 if you want the cursor flush against the edge of the view.

Requirements

micro 2.0.0 or newer.

My other plugins

  • palette — a searchable palette for micro: help topics, options, colorschemes, open buffers and files behind one keystroke.
  • ember — four warm truecolor colorschemes for micro, two of them transparent.
  • navz — keyboard-first navigation for VS Code, and the companion to this plugin.

License

MIT

About

Viewport control for the micro editor: scroll the cursor line to top or bottom, and half-page jumps that bring the cursor with you, centered.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages