Is there a way to call vi/vim from the shell to format text? It would be like running a vim-golf sequence from the command line.
It is so easy to compare effects of commands in vim that I can easily test a few options and identify a workable solution. I would like to be able to incorporate those command sequences into command line options.
I have tried something simple like
vi -c ":%s/./x/" but it that doesn't seem to work at all in msysgit vim. Really, I would only expect it to do that change and show me the open buffer.
vi -c ':%s/./x/' (with ' instead of ") does run the command on the buffer, but it is still kept in the buffer and not pushed back to stdout. Looks like Windows or msysgit was trying to magic my
% (fixed throughout the rest of the question).
What I want to be able to do is use it like you would grep/sed/awk/tr. The defaults are nice and not having to translate line break options from vim to the others would be helpful.
What I really want is a command line option for vim, say --doit='...' where I could specify what I would type, have it do that and spit out the resulting buffer. Something like this would spit out and x for every character in the result of an
ls -l command:
ls -l | vi --doit=':%s/./x/g' -
This would reformat text according to linebreaks (assuming textwidth and formatting options are set correctly):
vi --doit='ggqG' sometextfile.txt
It is difficult to search for a solution to this because of the convolution between shell command line and the vim command mode line.
Anyone know if this is possible?