On 12/09/09 12:44, Peter l Jakobi wrote:
>
> On Fri, Sep 11, 2009 at 07:39:09AM -0700, Joseph Boiteau wrote:
>> I would like to use the reindenting functionality (ie: "gg=G") based
>> on vim indent files, but without getting into vim..
>
> If I interpret this correctly, you seem to want to use vim commands
> outside of interactive vim?
>
>> I recently discover /usr/share/vim/vim72/macros/less.sh, which use the
>> vim power to make a less-like command with syntax highlighting.
>> I'm pretty sure the same is possible to reindent any source file.
>
> I played with the old vimsh vimscript-from-commandline a while ago.
> The experimental results are at
>
> http://www.vim.org/scripts/script.php?script_id=2768
>
> Seems to work for me, except for a bug I don't understand at all:
> printing commands (seen with g//p) don't seem to allow proper
> redirection to a register and kind of spew their output on the tty
> plus variable plus excess white-space. So use :w or echo to "sane"
> generate output.
>
> Just tested: While vim still has excess tty interaction and screen
> blanking, I actually managed to run the vimscript even from a cronjob,
> "35 12 * * * vimscript.range 13 15" did work and correctly replied by
> email with "13 14 15", much to my surprise:
>
> 1:0 for headless vim against jakobi :)
>
> #!/usr/bin/env vimscript
> # vimscript.range - trivial example to count from $1 to $2
>
> if $ARG0<2 | echo "Usage: ".expand("%:t")." fromNr toNr" | return | endif
> let nr=$ARG1+0
> while nr<= $ARG2+0
> echon nr.' '
> let nr=nr+1
> endwhile
> echo ''
>
>
If you have the Vim source, there is an example of a "batch Vim job" as
the "vimtags" target in the runtime/doc/Makefile .
Since I don't know how to use sed or awk (oh, I could bone up on the
manuals, but I know Vim, so what's the use?), I use Vim instead: for
instance, here is my full script for updating the runtime files (I run
it from the top-level directory "for building", in my case
~/.build/vim/vim72 ):
> #!/bin/bash
> date
> rsync -avzcP --delete --exclude="/dos/" ftp.nluug.nl::Vim/runtime/ ./runtime/
> 2>&1 | tee rsync.log
> vim -es -u NONE -c '%s/^.*\r//' -cx rsync.log
The last line runs Vim to "prettify" the log after the fact by
eliminating lines ended by a CR and no LF, which were "erased" on the
display by what came after the CR during the "actual" run. (This takes
advantage of the fact that the * multi is "greedy".)
See in particular
:help -e
:help -s-ex
Best regards,
Tony.
--
"I am not now, and never have been, a girlfriend of Henry Kissinger."
-- Gloria Steinem
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---