Hi,
Haslett, Garvin schrieb am 22.09.2021 um 13:04:
> Following the web page listed below I've created the following command alias in my .vimrc to conveniently prettify .json files:
> command! Pj %!python -m json.tool
>
> It works great but, ideally, I'd like to specify ranges. I tried the following:
> command! -range=% Pj !python -m json.tool
> But the command just hangs until such times as I Ctrl-C to abort.
>
> I'm surprised by this since entering `3,4!python -m json.tool` at the command buffer works as expected.
>
> What subtlety am I missing here?
you need to tell Vim where you want to insert the range into
the replacement text for the user-defined command. You do this
by including the escape sequence <range> in the replacement
text.
In your case
:command! -range=% Pj <range>!python -m json.tool
should do the trick.
Regards,
Jürgen