JSON editor with vim-style keybindings
Project description
jvim
JSON editor with vim-style keybindings, built with Textual.
Features
- Vim-style modal editing - Normal, Insert, Command, and Search modes
- Syntax highlighting - JSON-aware colorization
- JSON validation - Real-time validation with error reporting
- JSONPath search - Search using JSONPath expressions (
$.foo.bar) - JSONL support - Edit JSON Lines files with smart formatting
- Embedded JSON editing - Edit JSON strings within JSON with nested level support
- Visual mode - Character-wise (
v) and line-wise (V) selection withd/y/coperators - Folding - Collapse/expand JSON blocks and long string values
- Bracket matching - Jump to matching brackets with
% - Undo/Redo - Full undo history
Installation
pip install jvim
Usage
# Open a file
jvim data.json
# Open in read-only mode
jvim -R data.json
# Create new file
jvim newfile.json
Also available as jvi and jv shortcuts.
JSONL Support
jvim provides special handling for JSON Lines (.jsonl) files:
- Pretty-printed editing: Each JSONL record is automatically formatted with indentation for easy reading and editing
- Compact saving: When you save, each record is minified back to a single line, preserving the JSONL format
- Record numbers: A second column shows the record number (1, 2, 3...) for easy navigation
- Floating header: When scrolling through a multi-line record, the physical line number stays visible at the top
Example: A JSONL file with two records:
{"name": "Alice", "age": 30}
{"name": "Bob", "age": 25}
Opens in jvim as:
{
"name": "Alice",
"age": 30
}
{
"name": "Bob",
"age": 25
}
And saves back to the original compact format.
JSONPath Search
jvim supports powerful JSONPath searching with value filtering.
Basic JSONPath
Search patterns starting with $. or $[ are automatically recognized as JSONPath:
/$.name # Find the "name" field
/$..email # Find all "email" fields (recursive)
/$.users[0] # First user
/$.users[*].name # All user names
Value Filtering
You can filter search results by value using comparison operators:
| Operator | Description | Example |
|---|---|---|
= |
Equals | $.status="active" |
!= |
Not equals | $.status!=null |
> |
Greater than | $.age>18 |
< |
Less than | $.price<100 |
>= |
Greater or equal | $.count>=5 |
<= |
Less or equal | $.count<=10 |
~ |
Regex match | $.email~@gmail\.com$ |
Examples
/$.users[*].age>30 # Users older than 30
/$.items[*].status="active" # Items with active status
/$..name~^J # All names starting with J
/$.price<=1000 # Price 1000 or less
/$.config.enabled=true # Enabled configs
Search Modifiers
| Suffix | Description |
|---|---|
\j |
Force JSONPath mode for ambiguous patterns |
\c |
Case insensitive (for regex text search) |
\C |
Case sensitive (for regex text search) |
History
Search and command history is automatically saved to ~/.jvim/history.json and restored on next launch. Use arrow keys (↑/↓) to navigate history in search (/) and command (:) modes.
Embedded JSON Editing
JSON files often contain escaped JSON strings as values. jvim lets you edit these nested JSON structures naturally.
How it works
- Position your cursor on a line containing a JSON string value
- Type
ejin normal mode - A new editor panel opens with the parsed and formatted JSON
- Edit the embedded JSON with full syntax highlighting and validation
- Save with
:wto update the parent document (minified) or:qto cancel
Nested levels
You can edit embedded JSON within embedded JSON:
- The panel title shows the current nesting level:
Edit Embedded JSON (level 1) - A
[+]indicator appears when you have unsaved changes :wsaves to the parent document and continues editing:wqsaves and returns to the previous level:q!discards changes and returns to the previous level
Example
Given this JSON:
{
"config": "{\"host\": \"localhost\", \"port\": 8080}"
}
Using ej on the config line opens:
{
"host": "localhost",
"port": 8080
}
After editing and saving, the parent is updated with the minified result.
Keybindings
Use :help inside jvim to see the full keybinding reference.
License
MIT
Project details
Release history Release notifications | RSS feed
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 jvim-0.3.1.tar.gz.
File metadata
- Download URL: jvim-0.3.1.tar.gz
- Upload date:
- Size: 49.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f95e943d9ad949246a476b92daa987294d14a48ffbd85aa41640cc56e855ff7
|
|
| MD5 |
3064af521ec029028060003a2c20bf6f
|
|
| BLAKE2b-256 |
a233d8a2d2baa0ee270fcbc1a40b85e1a04a91a47c3b513565aa1f9c184eac14
|
File details
Details for the file jvim-0.3.1-py3-none-any.whl.
File metadata
- Download URL: jvim-0.3.1-py3-none-any.whl
- Upload date:
- Size: 38.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb18cc4bfc02b9a303e48b2da8a7262aae6a9fa89ef9e8e9ff2efe70bdebbde9
|
|
| MD5 |
2742cd3132c1dd7457b9fdb860b0f1a8
|
|
| BLAKE2b-256 |
75237f287978dbdd7dbf4f71944fe5512814dcc685f2e973bd9ec13f76f9f185
|