../
2022-12-03
First, create a Vim script. For example, a script to automatically wrap text at the 70th column is as follows:
:set tw=70
gggqG
:wq
Save it as ~/.vim/scripts/wrap, then you can process a file:
vim -s ~/.vim/scripts/wrap input.txt
If you want to use stdin as input and stdout as output, enabling it to be piped and called by other programs, you can wrap it in a Bash script:
#!/bin/bash
BUF=/tmp/$(head -c 15 /dev/urandom | base32)
cat > $BUF
/usr/bin/vim -s ~/.vim/scripts/wrap $BUF 1>/dev/null 2>/dev/null
cat $BUF
rm $BUF
Thus, a small tool is completed.
Mistivia - https://mistivia.com