Sunday, May 22, 2011

Re: bash script using vim commands?

Hi Marcin!

On Sa, 21 Mai 2011, Marcin Szamotulski wrote:

> On 02:26 Sat 21 May , shawn wilson wrote:
> > On May 21, 2011 12:30 AM, "Antonio Recio" <amdx64bt@gmail.com> wrote:
> > >
> > > The two commands to delete the comments of C++ files are:
> > > :%s!\s*//.*\|/\*\_.\{-}\*/
> > > :g/^\s*$/d
> > >
> > > How I can add this commands to my bash script?
> > >
> >
> > The right tool for the job I think: sed, awk, perl, lisp, etc. I don't think
> > vim is the right tool.
> >
> > That said, I'm sure there's a way. OTOH, if you're a hammer, everything
> > looks like a nail :)

I would use one of the :argdo/windo/bufdo/tabdo commands:
:args **
:argdo | ... (your commands here) | :up

(:upd makes sure your file will be written before changing to the next
file. That would fail because of unsaved changes, unless you'd the
'hidden' or autowriteall setting).

This of course clobbers your argument list. So you might want to use a
different of these commands. See also:

:h :argdo
:h :windo
:h :tabdo
:h :bufdo

regards,
Christian

--
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

No comments: