navz
Move around your code without reaching for the mouse.
navz gives VS Code three things: jump your cursor to any word you can see in two
keystrokes, put the line you're reading exactly where you want it on screen, and
move half a screen at a time without losing your place.
There are no modes to enter and nothing to learn beyond the handful of
keybindings below.
Extension: https://marketplace.visualstudio.com/items?itemName=vish-navz.navz

Jump to any word
Press Alt+Enter. Every word on screen gets a two-letter label. Type the first
letter — labels that don't match dim immediately, so you can see your input
landing. Type the second letter and your cursor is there.
Press Escape at any point to cancel.
Select to a word
Alt+Shift+Enter works the same way, but extends your selection from where you
are to the word you pick instead of just moving the cursor. If you already have
a selection, the anchor stays put and only the active end moves.
Put the current line where you want it
Sometimes you don't need to move the cursor — you just want the code you're
reading somewhere more comfortable on screen. Alt+Z followed by one key moves
the view and leaves your cursor exactly where it is:
Alt+Z Z — current line to the center
Alt+Z T — current line to the top
Alt+Z B — current line to the bottom
Reading a function signature with the body below it? Alt+Z T. Want context on
both sides? Alt+Z Z.
By default the cursor is anchored flush against the edge. VS Code sometimes
shifts the view by a few lines the next time you move the cursor — to clear
sticky scroll at the top, or a partially visible row at the bottom. If that
bothers you, set navz.scrollMargin to leave a cushion:
"navz.scrollMargin": 4
The cursor then lands that many lines inside the edge and nothing shifts
afterwards. editor.cursorSurroundingLines is respected either way — whichever
of the two is larger wins.
Move half a screen
Alt+D and Alt+U move down and up by half a screen. Unlike the Alt+Z
commands, these bring the cursor along, and it lands centered — so you always
know where it is after a few of them.
Alt+Shift+D and Alt+Shift+U do the same while extending the selection.
Movement counts display rows, so half a screen means half of what you can
actually see, whether or not word wrap is on.
Keybindings
| Keybinding |
Description |
Cursor |
Alt+Enter |
Jump cursor to a word |
moves |
Alt+Shift+Enter |
Select from cursor to a word |
moves |
Escape |
Exit jump mode |
— |
Alt+Z Z |
Current line to center |
stays |
Alt+Z T |
Current line to top |
stays |
Alt+Z B |
Current line to bottom |
stays |
Alt+D |
Half page down |
moves |
Alt+U |
Half page up |
moves |
Alt+Shift+D |
Half page down, extending selection |
moves |
Alt+Shift+U |
Half page up, extending selection |
moves |
On macOS the half-page motions are Ctrl+D, Ctrl+U, Ctrl+Shift+D and
Ctrl+Shift+U instead — Option+U is a dead key for umlaut input there, so it
never reaches the editor. They match vim's originals, and they only apply while
the editor has focus, so Ctrl+U still clears the line in the terminal.
Every command is also in the Command Palette under navz:, and every binding
can be remapped in keybindings.json.
The Alt+Z prefix shadows VS Code's Alt+Z (toggle word wrap), which stays
available from the View menu and the Command Palette.
Coming from vim?
The keys were chosen to match what you already have in your fingers:
| navz |
vim |
Alt+Z Z / Alt+Z T / Alt+Z B |
zz / zt / zb |
Alt+D / Alt+U |
Ctrl-D / Ctrl-U |
Alt+Enter |
easymotion / leap / hop |
One deliberate difference: vim's Ctrl-D keeps the cursor at the same row
within the window, while navz centers it. Centering means never hunting for the
cursor after a couple of half-page moves.
navz isn't a vim emulator and doesn't try to be. Vim is a vast ocean, and this
is one small slice of it — the few motions that are worth having on their own,
without modes and without taking on the rest. If you're already happy in a vim
emulator you don't need navz; jump mode conflicts with them anyway. It's for
everyone else who'd still rather not reach for the mouse.
Companion plugin
scrollz provides the same viewport
commands for the micro editor.
Known limitations
- Up to 676 words can be labeled at once (26×26 codes:
aa–zz). On very large
viewports this limit may be reached.
- Jump mode conflicts with extensions that also override the
type command
(e.g. some vim emulators). navz shows a warning and exits gracefully if this
happens. The Alt+Z, Alt+D and Alt+U commands are unaffected.
Release notes
See CHANGELOG.md. Version 1.0.0 moves the viewport commands off
Ctrl+I, which collided with inline chat, onto the Alt+Z prefix.
License
MIT