argdo does not execute macro on all args files

160 views
Skip to first unread message

Asis Hallab

unread,
Dec 6, 2013, 5:26:56 AM12/6/13
to vim...@googlegroups.com
Dear Vimmers,

I just had a surprising experience with Vim's argdo command.

I did the following:
1) In my ruby on rails project I opened Vim and set the argument list with
:args `find . -name '*.rb'`
After this, I could see, that all Ruby files in the project were in
the argument list
2) I recorded a macro to add a simple comment line at the top of the file
ggO# encoding: utf-8^[
3) I executed this macro on all files in the argument list:
:argdo :norm @q

Interestingly only a subset of the files in the argument list got
changed, others were untouched.
In fact it only affected the files in a certain sub-directory.

Does anyone have a clue why this happened?

I am using (precompiled) MacVim 7.3 which is the latest available version.

Your help will be much appreciated.

Kind regards!

LCD 47

unread,
Dec 6, 2013, 5:44:34 AM12/6/13
to vim...@googlegroups.com
On 6 December 2013, Asis Hallab <asis....@gmail.com> wrote:
> Dear Vimmers,
>
> I just had a surprising experience with Vim's argdo command.
>
> I did the following:
> 1) In my ruby on rails project I opened Vim and set the argument list with
> :args `find . -name '*.rb'`
> After this, I could see, that all Ruby files in the project were in
> the argument list
> 2) I recorded a macro to add a simple comment line at the top of the file
> ggO# encoding: utf-8^[
> 3) I executed this macro on all files in the argument list:
> :argdo :norm @q
>
> Interestingly only a subset of the files in the argument list got
> changed, others were untouched.
> In fact it only affected the files in a certain sub-directory.
>
> Does anyone have a clue why this happened?
[...]

Perhaps it aborted at an error? Macros are tricky like that.

/lcd

Tim Chase

unread,
Dec 6, 2013, 9:31:44 AM12/6/13
to vim...@googlegroups.com
On 2013-12-06 11:26, Asis Hallab wrote:
> 1) In my ruby on rails project I opened Vim and set the argument
> list with :args `find . -name '*.rb'`

Just as a side note, Vim should be able to do this without relying on
"find" by using

:args **/*.rb

which you can read about at

:help starstar

I've been using that a LOT recently.

(re. your actual question, I suspect that LCD is right, that the
macro is failing on the files, so you'd want to tune/test your macro
on those files to make sure they aren't breaking)

-tim



Asis Hallab

unread,
Dec 6, 2013, 9:37:03 AM12/6/13
to vim...@googlegroups.com
Hi there!

2013/12/6 LCD 47 <lcd...@gmail.com>:
Did not get any error message. Not even with
:messages

I just tested it on another computer (Linux Mint with latest binary
vim 7.3). Here it works!!!!

Stranger and stranger…

@Tim
>:args **/*.rb

Yes, I do know the starstar notation. Just an old habbit to use :args `find… `

Cheers!

Nikolay Pavlov

unread,
Dec 6, 2013, 9:45:20 AM12/6/13
to vim...@googlegroups.com


On Dec 6, 2013 6:37 PM, "Asis Hallab" <asis....@gmail.com> wrote:
>
> Hi there!
>
> 2013/12/6 LCD 47 <lcd...@gmail.com>:
> > On 6 December 2013, Asis Hallab <asis....@gmail.com> wrote:
> >> Dear Vimmers,
> >>
> >> I just had a surprising experience with Vim's argdo command.
> >>
> >> I did the following:
> >> 1) In my ruby on rails project I opened Vim and set the argument list with
> >> :args `find . -name '*.rb'`
> >> After this, I could see, that all Ruby files in the project were in
> >> the argument list
> >> 2) I recorded a macro to add a simple comment line at the top of the file
> >> ggO# encoding: utf-8^[
> >> 3) I executed this macro on all files in the argument list:
> >> :argdo :norm @q
> >>
> >> Interestingly only a subset of the files in the argument list got
> >> changed, others were untouched.
> >> In fact it only affected the files in a certain sub-directory.
> >>
> >> Does anyone have a clue why this happened?
> > [...]
> >
> >     Perhaps it aborted at an error?  Macros are tricky like that.
> >
>
> Did not get any error message. Not even with
> :messages

It is not necessary seen. Try macro "fad$" when there is no "a" on the line: it aborts, but no error messages are displayed: definition of the error that aborts the macro is wider. I do not see where an error is possible in your macro. I would have used append(0) though and not a macro in this case.

>
> I just tested it on another computer (Linux Mint with latest binary
> vim 7.3). Here it works!!!!
>
> Stranger and stranger…
>
> @Tim
> >:args **/*.rb
>
> Yes, I do know the starstar notation. Just an old habbit to use :args `find… `
>
> Cheers!
>

> --
> --
> 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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages