Browse Source

Add format json (jq) with shortcut

master
Ryan Reed 1 year ago
parent
commit
1efbdd7965
2 changed files with 7 additions and 2 deletions
  1. +1
    -1
      dot_config/vim/README.md
  2. +6
    -1
      dot_config/vim/vimrc

+ 1
- 1
dot_config/vim/README.md View File

@ -84,7 +84,7 @@ Below is a list of currently installed plugins:
| `<leader><F2>` | Remove trailing whitespace from file | |
| `<leader>a<delimiter>` | Accept various common delimiters for tabulizing blocks of code (e.g. `varname = something`, = being the delimiter) | Tabular |
| `<leader>d` | Add delimiters around entire line (normal mode) or selection (visual mode) | vim-surround |
| `<leader>j` | Pretty print json (current open file) | |
| `<leader>fj` | Pretty print json using jq (current open file) | |
| `<leader>D` | Add delimiters around current word (normal mode) | vim-surround |
| `<leader>q` | Format a paragraph/line to better fit the textwidth | |
| `<leader>p` | Toggle paste mode | |


+ 6
- 1
dot_config/vim/vimrc View File

@ -263,7 +263,12 @@
nmap <leader>d yss
nmap <leader>D ysiw
nnoremap <leader>j :%!python -m json.tool<CR> " Pretty print json
" Format Commands (start with f for format)
" nnoremap <leader>j :%!python -m json.tool<CR> " Use python for pretty printing json
nnoremap <silent> <Leader>fj <Cmd>%!jq<CR> " Use jq for pretty printing JSON file
nnoremap <silent> <Leader>fcj <Cmd>%!jq --compact-output<CR>
vnoremap <silent> <Leader>fj :'<,'>!jq<CR> " Use jq for pretty printing JSON selection
vnoremap <silent> <Leader>fcj :'<,'>!jq --compact-output<CR>
" 06 - Neovim LSPs
if has('nvim')


Loading…
Cancel
Save