A powerful documentation viewer with Vimium-C style keyboard navigation and fully customizable shortcuts.
Project description
DOCV: Documentation Viewer with Vim Navigation
A powerful documentation viewer for html files generate by Sphinx, MkDocs, Docusaurus, or any static HTML files, with Vimium-C style keyboard navigation and fully customizable shortcuts.
Features
- 🎯 Vim-style Navigation - Browse docs like a pro with keyboard shortcuts
- ⚙️ Fully Customizable - Configure all shortcuts via
.envfile - 🔗 Link Hints - Vimium-C style link selection
- 📝 Text Selection - Mouse drag and Ctrl+A/C always work
- 🌓 Dark Mode - Toggle with Alt+Shift+D
- 🔄 Two-key Commands - Support for
gg,gi,yy, etc. - ⚡ Smart Hints - Intelligent hint matching with timeout
Installation
pip install docv
Requirements
pip install pywebview envdot
# or
pip install -r requirements.txt
Optional
pip install licface # For better color helper in terminal (optional)
Quick Start
- Create
.envfile with your documentation directory or copy/rename .env.examples file:
DOCS_DIR=/path/to/your/docs
- Run the viewer:
docs mydocs
This will open DOCS_DIR/mydocs/index.html
Usage
Basic Commands
# View documentation
docs <path>
# View with custom window size
docs <path> --width 1200 --height 800
# Disable Vim mode
docs <path> --no-vim
# Show current shortcuts configuration
docs --show-config
# Debug mode
docs <path> --debug
Examples
# Open mydocs docs
docs mydocs
# Open specific HTML file
docs path/to/file.html
# Multiple documentation directories (in .env)
DOCS_DIR=/path/to/docs1,/path/to/docs2,/path/to/docs3
Default Keyboard Shortcuts
Scrolling
j- Scroll downk- Scroll uph- Scroll leftl- Scroll rightd- Page downu- Page upgg- Go to top (two-key command)G- Go to bottom
Navigation
Shift+H- Go back in historyShift+L- Go forward in historyr- Reload pageq- Quit application
Links
f- Show link hints (click in current tab)F- Show link hints (open in new tab)- Type hint letters to activate link
ESC- Cancel hint mode
Actions
yy- Copy current URL to clipboard (two-key command)gi- Focus first input field (two-key command)
Other
Alt+Shift+D- Toggle dark modeESC- Cancel current action/clear buffer
Text Selection (Always Available)
- Mouse drag - Select text
- Ctrl+A / Cmd+A - Select all
- Ctrl+C / Cmd+C - Copy
- Shift+Arrow - Extend selection
- Double-click - Select word
- Triple-click - Select paragraph
- Right-click - Context menu (always enabled)
Customizing Shortcuts
You can customize ALL shortcuts by adding VIM_* variables to your .env file.
Configuration Variables
Scrolling Shortcuts
VIM_SCROLL_DOWN=j # Default: j
VIM_SCROLL_UP=k # Default: k
VIM_SCROLL_LEFT=h # Default: h
VIM_SCROLL_RIGHT=l # Default: l
VIM_PAGE_DOWN=d # Default: d
VIM_PAGE_UP=u # Default: u
VIM_TOP=gg # Default: gg (two-key)
VIM_BOTTOM=G # Default: G
Navigation Shortcuts
VIM_BACK=H # Default: H (use with Shift)
VIM_FORWARD=L # Default: L (use with Shift)
VIM_RELOAD=r # Default: r
VIM_QUIT=q # Default: q
Link Shortcuts
VIM_HINTS=f # Default: f
VIM_HINTS_NEW_TAB=F # Default: F
Action Shortcuts
VIM_COPY_URL=yy # Default: yy (two-key)
VIM_FOCUS_INPUT=gi # Default: gi (two-key)
Settings
VIM_SCROLL_STEP=60 # Pixels to scroll per j/k press
VIM_HINT_CHARS=asdfghjkl # Characters used for hints
VIM_BUFFER_TIMEOUT=1000 # Milliseconds to wait for second key
VIM_HINT_TIMEOUT=500 # Milliseconds to wait in hint mode
VIM_DARK_MODE_TOGGLE=D # Key for dark mode (with Alt+Shift)
Example: Custom Configuration
Create a .env file with your preferences:
# Documentation directories
DOCS_DIR=/home/user/docs,/opt/docs
# Custom Vim shortcuts - Use arrow keys instead of hjkl
VIM_SCROLL_DOWN=s
VIM_SCROLL_UP=w
VIM_PAGE_DOWN=x
VIM_PAGE_UP=e
# Custom two-key commands
VIM_TOP=gt # Type 'gt' to go to top
VIM_COPY_URL=cy # Type 'cy' to copy URL
VIM_FOCUS_INPUT=fi # Type 'fi' to focus input
# Different hint characters (home row only)
VIM_HINT_CHARS=asdfjkl
# Slower scrolling
VIM_SCROLL_STEP=40
# Faster buffer timeout
VIM_BUFFER_TIMEOUT=800
How It Works
Two-Key Commands
Commands like gg, gi, and yy work as follows:
- Press first key (
g,y) - Status bar shows "Buffer: g"
- Press second key within timeout (default 1000ms)
- Command executes if valid, or buffer clears on timeout
Important: The system checks two-key commands BEFORE single-key commands, so gi will always trigger "focus input" rather than pressing g then i separately.
Hint Mode
Inspired by Vimium-C:
- Press
fto enter hint mode - Yellow hints appear on all clickable elements
- Type hint letters to filter
- When only one match remains, it activates automatically
- If there's an exact match but also longer possibilities:
- Exact match turns red
- Wait 500ms for auto-activation, or
- Type more letters for longer hints
- Example: Hints
d,df,dkexist- Type
d→ Wait or typef/k - Type
d+ wait 500ms → Activatesd - Type
df→ Activatesdfimmediately
- Type
Troubleshooting
Text Selection Not Working
The app automatically enables text selection on every page. If it doesn't work:
- Check if the page has custom JavaScript blocking selection
- Try opening in
--debugmode to see console messages - Use
Ctrl+Aas fallback - this always works
Shortcuts Not Working
- Make sure you're not in an input field (Vim mode is disabled in inputs)
- Check if modifier keys are pressed (Ctrl/Alt/Cmd disable Vim mode)
- Verify your
.envconfiguration with--show-config - Check console (F12) for error messages in debug mode
Hints Not Appearing
- The page may have no visible links
- Try pressing
fagain - Check
VIM_HINT_CHARSin your.envis valid
Right-Click Disabled
The app automatically enables right-click. If it's still disabled:
- The page may be re-disabling it with JavaScript
- Try in debug mode to see console messages
Advanced Usage
Multiple Documentation Sets
# .env file
DOCS_DIR=/docs/python,/docs/javascript,/docs/rust
Then you can open docs from any of these directories:
docs requests # Looks in all three directories
docs axios
docs tokio
Window Positioning
# Open at specific position and size
docs flask --width 1200 --height 900 --x 100
Disable Vim Mode
# Use as regular browser without Vim shortcuts
docs django --no-vim
Technical Details
Architecture
- Python Backend: Uses
pywebviewto create native window - JavaScript Frontend: Vim navigation injected into each page
- Configuration: Loaded via
envdotfrom.envfile - Event Handling: Uses event bubbling (not capture) to avoid conflicts
Text Selection Strategy
The app ensures text selection works by:
- NOT intercepting Ctrl/Cmd/Alt key combinations
- NOT intercepting Shift combos (except Shift+H/L for navigation)
- Using
stopPropagation()on selection events to prevent page blocking - Injecting CSS to force
user-select: texton all elements
Browser Compatibility
- Uses standard Web APIs (no browser-specific code)
- Should work on any
pywebviewbackend (Qt, GTK, Edge, etc.) - Tested on Windows, Linux, macOS
FAQ
Q: Why can't I select text after navigating to a new page?
A: The app reinjects the selection enabler on every page load. If it still doesn't work, the page might be using aggressive anti-selection JavaScript.
Q: Can I use Vim mode on any website?
A: Yes! While designed for local documentation, it works on any HTML file or website.
Q: Does it support Visual mode like Vim?
A: No, text selection is handled by the browser natively. Use mouse or Shift+arrows.
Q: Can I have more than two-key commands?
A: Currently limited to one and two-key commands. Three+ key commands would require significant changes.
Q: How do I reset to default shortcuts?
A: Remove all VIM_* variables from your .env file, or delete the .env file.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Hadi Cahyadi - cumulus13@gmail.com
Contributing
Found a bug or want a feature? Feel free to:
- Check existing issues
- Create detailed bug report
- Suggest improvements
Acknowledgments
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docv-1.0.6.tar.gz.
File metadata
- Download URL: docv-1.0.6.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e897d6cece3897fe972f3fcfbc24c5274d80fd6a0475843a4f04ed97812aedc
|
|
| MD5 |
6330f1a3f071d83625fce415f8c26d69
|
|
| BLAKE2b-256 |
ddc04b769fbfb8f0b5533452f20200efb810725e0006bf35f210fcc3fe25bf6a
|
File details
Details for the file docv-1.0.6-py3-none-any.whl.
File metadata
- Download URL: docv-1.0.6-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ff8e573d1ce1b0ea1b41a611805abb1a6141cbb2dd0ce1807375f3e60adc338
|
|
| MD5 |
fb2a212378db1beb9b1f7d51ee3017c6
|
|
| BLAKE2b-256 |
8b826301d0de42ef5b35133829cb34db857d53c36d839ba63a047e85b936b966
|