Friday, April 2, 2021

Re: How to setup an external command to indent bash script?

On 4/2/21 3:52 PM, Peng Yu wrote:
> I want to use shfmt to indent bash script in vim instead of using the
> default vim indenter. Could anybody show me how to set this up in vim?

I would play with the formatprg setting.

:help formatprg

> shfmt -l -w script.sh

Based on my read of the help section, it looks like formatprg expects to
read STDIN and write to STDOUT. So you might need some sort of wrapper
to read Vim's STDOUT to a file, shfmt said file, then write said file
back to Vim's STDIN.

But I suspect that this is eminently doable.



--
Grant. . . .
unix || die

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ed861df1-0a61-cae5-dfd9-8c576d664e92%40spamtrap.tnetconsulting.net.

No comments:

Post a Comment