Vim Style Navigation (with Settings + Enhanced)

Vim-style scrolling + hint(f/F), find(/ n/N), history(H/L), page ops(r t x*), misc(yy p o ?). UserScript-safe fallbacks.

作者
bianwenbo
今日安裝
0
安裝總數
0
評價
0 0 0
版本
2.2.0
建立日期
2025-08-31
更新日期
2025-09-01
尺寸
20.6 KB
授權條款
MIT
腳本執行於
所有網站

Vim Style Navigation (with Settings + Enhanced)

A Tampermonkey userscript that brings Vim-style navigation to the web:

  • Scrolling: hjkl, d/u, gg/G
  • Link hints: f / F
  • Find: /, n / N
  • History: H / L
  • Page ops: r, t, x*
  • Misc: yy, p, o, ?

* x can only close tabs that were opened by scripts (browser restriction).


✨ Features

Scrolling

  • h / l — scroll left/right
  • j / k — scroll down/up
  • d / u — page down/up (distance = baseStep + extraPage)
  • gg / G — jump to top/bottom

Link Hint

  • f — open hinted link in current tab
  • F — open hinted link in new tab (uses GM_openInTabwindow.open fallback)

Find

  • / — open lightweight find bar
  • n / N — next / previous match (based on window.find)

History & Page Ops

  • H — back, L — forward
  • r — reload, t — new tab, x — close tab*
  • J/K tab switching is not available in UserScript due to browser permissions.

Misc

  • yy — copy current page URL (clipboard API / GM fallback)
  • p — open URL from clipboard (or prompt fallback)
  • o — open URL or search (prompt)
  • ? — help overlay

Smart input detection: Hotkeys are disabled inside INPUT / TEXTAREA / SELECT / contentEditable / designMode=on.


⚙️ Settings (Tampermonkey Menu)

Open Tampermonkey → this script → Menu Commands to adjust:

  • Base Step (baseStep, default 100)
  • Extra Page (extraPage, default 300)
  • gg Interval (ggIntervalMs, default 600 ms)
  • Native Smooth Scroll (useNativeSmooth, on/off)
  • Ignore Modifier Keys (ignoreWithModifier, on/off)
  • Exclude Sites: add/remove URL prefixes or regex (e.g. /.*\.notion\.site\//)
  • Hint Chars (hintChars), Hint Max Letters (hintMaxLetters)
  • Reset Defaults

🚀 Installation

  1. Install Tampermonkey for your browser.
  2. Add this userscript (paste raw URL or code).
  3. Refresh any page and start using Vim keys.

🛡️ Permissions & Notes

  • Uses GM_openInTab, GM_setClipboard, GM_getValue/GM_setValue, GM_registerMenuCommand.
  • Clipboard read may require HTTPS and user permission; script falls back to prompt when needed.
  • Some sites use custom scroll containers; extreme layouts may reduce hint accuracy.
  • Recommended to exclude heavy editors: Google Docs, Notion, Figma, Gmail, etc.
  • UserScript cannot switch browser tabs programmatically (security limitation).

❓ Troubleshooting

  • Keys don’t work: Check if focus is inside an input/editor; confirm the site isn’t in the exclude list.
  • x doesn’t close: Browsers only allow scripts to close tabs that they opened.
  • Clipboard issues: Grant permission or use the prompt fallback.
  • Conflicts: If a site uses the same keys, enable “Ignore Modifier Keys” or add the site to Exclude.

🗺️ Keymap (Quick Reference)

Category Keys Action
Scroll j / k Down / Up
h / l Left / Right
d / u Page Down / Up (base+extra)
gg / G Top / Bottom
Hint f / F Open link (current / new tab)
Find /, n / N Open find, Next / Prev
History H / L Back / Forward
Page r / t / x Reload / New tab / Close tab*
Misc yy / p / o / ? Copy URL / Open from clipboard / Open or search / Help

📜 License

MIT License © Wenbo Bian