Skip to main content

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
  • 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

  1. Position your cursor on a line containing a JSON string value
  2. Type ej in normal mode
  3. A new editor panel opens with the parsed and formatted JSON
  4. Edit the embedded JSON with full syntax highlighting and validation
  5. Save with :w to update the parent document (minified) or :q to 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
  • :w saves 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

Movement

Key Action
h j k l Left/Down/Up/Right
w b Word forward/backward
0 $ ^ Line start/end/first char
gg G File start/end
% Jump to matching bracket
PgUp PgDn Page up/down
Ctrl+d/u Half page down/up

Search

Key Action
/ Search forward
? Search backward
n N Next/previous match
$.path JSONPath search (auto-detect)
$.path=val JSONPath with value filter
$.path~regex JSONPath with regex filter
\j JSONPath suffix for patterns
\c \C Case insensitive/sensitive

Insert Mode

Key Action
i I Insert at cursor/line start
a A Append after cursor/line end
o O Open line below/above

Editing

Key Action
x Delete char
dd Delete line
dw d$ Delete word/to end
cw cc Change word/line
r{c} Replace char
J Join lines
yy p P Yank/paste after/before
u Undo
Ctrl+r Redo
. Repeat last edit
ej Edit embedded JSON string

Commands

Command Action
:w Save
:w {file} Save as
:e {file} Open file
:fmt Format JSON
:q Quit
:q! Quit (discard changes)
:wq Save and quit
:help Toggle help panel

License

MIT

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

jvim-0.2.0.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jvim-0.2.0-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file jvim-0.2.0.tar.gz.

File metadata

  • Download URL: jvim-0.2.0.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for jvim-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ab77523f689d48e627abedf585204d3c66dc970b56b803aea4f0b1fe879d7eee
MD5 c196831c86973e93373347a1cddf38ee
BLAKE2b-256 0d86ef115cdf7583874ea05e90ffc9c9e70c7f95b5b0a8db87889b33bc603389

See more details on using hashes here.

File details

Details for the file jvim-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jvim-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for jvim-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cee1ebcd3feb1726d729bc2ca8a8c6292b904cf20f6d4d601ddb42c4b1af225
MD5 27ed0c9bb78bfbd61583c3e7453b03da
BLAKE2b-256 b341a18fa9b6462d8feb27c0aff64f58ba822a08f6563bd56ad479cab6d29f51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page