Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.87 KB

README.md

File metadata and controls

64 lines (47 loc) · 1.87 KB

vim-jsonpath

A Vim plugin which provides ways of navigating JSON document buffers.

  • :JsonPath: Echoes the path to the identifier under the cursor.
  • :JsonPath path.to.prop: Searches the active buffer for the given path, placing the cursor on it if found.

More information is available via :help jsonpath.

Quick Start

" Install plugin (in this example using vim-plug)
Plug 'mogelbrod/vim-jsonpath'

" Optionally copy path to a named register (* in this case) when calling :JsonPath
let g:jsonpath_register = '*'

" Define mappings for json buffers
au FileType json noremap <buffer> <silent> <leader>d :call jsonpath#echo()<CR>
au FileType json noremap <buffer> <silent> <leader>g :call jsonpath#goto()<CR>

Python support in vim

While not required it is recommended to use a Vim environment with the +python3 feature enabled, since the plugin provides a python implementation that is much faster than the vimscript variant. You can check the availability using:

:echo has("python3")

Mappings

Mappings are not provided by default but can easily be added to your .vimrc.

  • If you only want mappings when working with .json files:

    au FileType json noremap <buffer> <silent> <leader>d :call jsonpath#echo()<CR>
    au FileType json noremap <buffer> <silent> <leader>g :call jsonpath#goto()<CR>
  • If you prefer global mappings:

    noremap <buffer> <silent> <leader>d :call jsonpath#echo()<CR>
    noremap <buffer> <silent> <leader>g :call jsonpath#goto()<CR>

Configuration

See :help jsonpath-configuration for the available configuration options.

Installation

Use vim-plug, Vundle, pathogen.vim or another Vim package manager.

Plug 'mogelbrod/vim-jsonpath' " example using vim-plug