vim 常用

Format JSON

:%!python -m json.tool

1. define custom function and use it

define function in .vimrc

function! FormatJSON()
:%!python -m json.tool
endfunction

use it in visual mode

:call FormatJSON()

2. map shortcut Ctrl + j

define command in .vimrc

nnoremap <C-j> :call Compile()<CR>

use it with Ctrl + j in normal mode

3. map shortcut =j

nmap =j :%!python -m json.tool<CR>

use it with =j in normal mode

上一篇:soap 路由


下一篇:C语言 · 积分之迷