I like to use shell-command-on-region for pretty printing a selected region of code with prettier.

After selecting a region, I type C-u M-| and then I use prettier --parser ruby as the shell command. This is working great. :)

Now, I also like to use TRAMP to open a ruby file on a remote system.

Unfortunately, shell-command-on-region does not seem to respect TRAMP. It attempts to execute a shell command on my local machine.

On the other hand, if I invoke shell-command unsing M-!, this executes a command on the remote machine.

Is there a way to make shell-command-on-region work together with TRAMP?

1 Answer 1


shell-command-on-region uses call-process-region, which doesn't support remote execution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.