vimrc: add keybind for formatting JSON with jq

This commit is contained in:
t14 2024-11-18 20:08:36 +01:00
parent 2662865051
commit b08fb429e5
Signed by: wanderer
SSH Key Fingerprint: SHA256:szgNfbjbimyesAS1xfRZ0DY3hcNv9xC9ocRCJjD4Wgg

@ -874,6 +874,15 @@ nmap <silent> <leader>tl :TestLast<CR>
nmap <silent> <leader>g :TestVisit<CR> nmap <silent> <leader>g :TestVisit<CR>
""" formatingt with jq as per https://davidisaksson.dev/posts/format-json-in-vim/
" Whole buffer
nnoremap <silent> <Leader>fj <Cmd>%!jq<CR>
nnoremap <silent> <Leader>fcj <Cmd>%!jq --compact-output<CR>
" Visual selection
vnoremap <silent> <Leader>fj :'<,'>!jq<CR>
vnoremap <silent> <Leader>fcj :'<,'>!jq --compact-output<CR>
" partially superseded by jasonccox/vim-wayland-clipboard (for "+) " partially superseded by jasonccox/vim-wayland-clipboard (for "+)
" still keeping the "* mappings " still keeping the "* mappings
" it however breaks <c-r> " it however breaks <c-r>