recursively edit the files with the same name

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

recursively edit the files with the same name

Zhengquan Zhang-2

Hello guys,
I have lots of files with the same name recursively under a directory,
some are in very deep directories. I would like to use a single
command
to open all this files and I need to change a single parameter in the
files. It is too time consuming to open them individually

Thank you!

Regards,
Zhengquan

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

fuzzymo

Assuming a unix-y environment:

find directoryname -name filename -exec vim \{\} \;

Fuzzy

On Wed, May 7, 2008 at 5:22 PM, zhengquan <[hidden email]> wrote:

>  Hello guys,
>  I have lots of files with the same name recursively under a directory,
>  some are in very deep directories. I would like to use a single
>  command
>  to open all this files and I need to change a single parameter in the
>  files. It is too time consuming to open them individually
>
>  Thank you!
>
>  Regards,
>  Zhengquan

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Zhengquan Zhang-2

Thanks, it works!

Zhengquan

On May 7, 4:28 pm, "Fuzzy Logic" <[hidden email]> wrote:

> Assuming a unix-y environment:
>
> find directoryname -name filename -exec vim \{\} \;
>
> Fuzzy
>
> On Wed, May 7, 2008 at 5:22 PM, zhengquan <[hidden email]> wrote:
> >  Hello guys,
> >  I have lots of files with the same name recursively under a directory,
> >  some are in very deep directories. I would like to use a single
> >  command
> >  to open all this files and I need to change a single parameter in the
> >  files. It is too time consuming to open them individually
>
> >  Thank you!
>
> >  Regards,
> >  Zhengquan
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Pete Johns-2
In reply to this post by Zhengquan Zhang-2
On Wed, 2008-05-07 at 14:22:59 -0700, zhengquan sent:
>Hello guys,
>I have lots of files with the same name recursively under a
>directory, some are in very deep directories. I would like to
>use a single command to open all this files and I need to change
>a single parameter in the files. It is too time consuming to
>open them individually
>
This is where zsh comes in handy
<http://en.wikipedia.org/wiki/Zsh>.

This will open all Makefiles under the current directory:

%   zsh
%   vim **/Makefile

If you need to make the same substitution in each of these files,
then argdo is your friend:

:argdo s!bash!zsh!g

See :help :argdo

Hope this helps;


--paj
--
Pete Johns                                   <http://johnsy.com/>
Contact Information                  <http://johnsy.com/contact/>
CIFS                           <http://johnsy.com/20080427070425>
Anchors Aweigh              <http://johnsy.com/albums/2466662191>

attachment0 (202 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Andy Kittner
In reply to this post by Zhengquan Zhang-2
On Wed, May 07, 2008 at 02:22:59PM -0700, zhengquan wrote:
>
>Hello guys,
>I have lots of files with the same name recursively under a directory,
>some are in very deep directories. I would like to use a single
>command
>to open all this files and I need to change a single parameter in the
>files. It is too time consuming to open them individually

I usually use
    :args **/the_file_name
for things like this.

Also if your 'single parameter' can be changed in an automated way
you may be interested in :argdo

For example:

    :argdo %s/Last-Changed: \(.*\)/\=strftime("%Y-%m-%d")/

would update the Last-Changed tag in all files you selected by :args

see:
    help :args
    help starstar-wildcard
    help :argdo


Andy
--
One learns to itch where one can scratch.
                -- Ernest Bramah

attachment0 (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Tony Mechelynck
In reply to this post by Zhengquan Zhang-2

On 07/05/08 23:22, zhengquan wrote:

> Hello guys,
> I have lots of files with the same name recursively under a directory,
> some are in very deep directories. I would like to use a single
> command
> to open all this files and I need to change a single parameter in the
> files. It is too time consuming to open them individually
>
> Thank you!
>
> Regards,
> Zhengquan

        gvim
        :cd ~/.build/Tom.Dick.Harry
        :args **/Makefile
        :argdo %s/\$(FOO)/$(BAR)/g | update
        :q

(untested, and assuming a bash or similar shell) will change "$(FOO)" to
"$(BAR)" (as explicit strings in both cases, no substitution) in every
"Makefile" in the directory "~/.build/Tom.Dick.Harry/" and below, down
to 30 levels deep. Replace **/ by **255/ to search 255 levels deep (the
maximum in Vim).

        :help :args
        :help starstar
        :help :argdo

Best regards,
Tony.
--
Gravity is an unforgiving motherfucker.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Zhengquan Zhang-2
In reply to this post by Pete Johns-2

I have always wanted to give a zsh a try, but it seems to be lot of
work
to completely migrate from bash to zsh.

Thanks.
Zhengquan

On May 7, 4:47 pm, Pete Johns <[hidden email]> wrote:

> On Wed, 2008-05-07 at 14:22:59 -0700, zhengquan sent:>Hello guys,
> >I have lots of files with the same name recursively under a
> >directory, some are in very deep directories. I would like to
> >use a single command to open all this files and I need to change
> >a single parameter in the files. It is too time consuming to
> >open them individually
>
> This is where zsh comes in handy
> <http://en.wikipedia.org/wiki/Zsh>.
>
> This will open all Makefiles under the current directory:
>
> %   zsh
> %   vim **/Makefile
>
> If you need to make the same substitution in each of these files,
> then argdo is your friend:
>
> :argdo s!bash!zsh!g
>
> See :help :argdo
>
> Hope this helps;
>
> --paj
> --
> Pete Johns                                   <http://johnsy.com/>
> Contact Information                  <http://johnsy.com/contact/>
> CIFS                           <http://johnsy.com/20080427070425>
> Anchors Aweigh              <http://johnsy.com/albums/2466662191>
>
>  application_pgp-signature_part
> 1KDownload

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Zhengquan Zhang-2
In reply to this post by Andy Kittner

Thanks, args rocks!
Zhengquan

On May 7, 4:54 pm, Andy Kittner <[hidden email]> wrote:

> On Wed, May 07, 2008 at 02:22:59PM -0700, zhengquan wrote:
>
> >Hello guys,
> >I have lots of files with the same name recursively under a directory,
> >some are in very deep directories. I would like to use a single
> >command
> >to open all this files and I need to change a single parameter in the
> >files. It is too time consuming to open them individually
>
> I usually use
>     :args **/the_file_name
> for things like this.
>
> Also if your 'single parameter' can be changed in an automated way
> you may be interested in :argdo
>
> For example:
>
>     :argdo %s/Last-Changed: \(.*\)/\=strftime("%Y-%m-%d")/
>
> would update the Last-Changed tag in all files you selected by :args
>
> see:
>     help :args
>     help starstar-wildcard
>     help :argdo
>
> Andy
> --
> One learns to itch where one can scratch.
>                 -- Ernest Bramah
>
>  application_pgp-signature_part
> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Zhengquan Zhang-2
In reply to this post by Andy Kittner

Thanks, args rocks!
Zhengquan

On May 7, 4:54 pm, Andy Kittner <[hidden email]> wrote:

> On Wed, May 07, 2008 at 02:22:59PM -0700, zhengquan wrote:
>
> >Hello guys,
> >I have lots of files with the same name recursively under a directory,
> >some are in very deep directories. I would like to use a single
> >command
> >to open all this files and I need to change a single parameter in the
> >files. It is too time consuming to open them individually
>
> I usually use
>     :args **/the_file_name
> for things like this.
>
> Also if your 'single parameter' can be changed in an automated way
> you may be interested in :argdo
>
> For example:
>
>     :argdo %s/Last-Changed: \(.*\)/\=strftime("%Y-%m-%d")/
>
> would update the Last-Changed tag in all files you selected by :args
>
> see:
>     help :args
>     help starstar-wildcard
>     help :argdo
>
> Andy
> --
> One learns to itch where one can scratch.
>                 -- Ernest Bramah
>
>  application_pgp-signature_part
> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Zhengquan Zhang-2
In reply to this post by Tony Mechelynck

Thanks Tony!
Zhengquan

On May 7, 5:02 pm, Tony Mechelynck <[hidden email]>
wrote:

> On 07/05/08 23:22, zhengquan wrote:
>
> > Hello guys,
> > I have lots of files with the same name recursively under a directory,
> > some are in very deep directories. I would like to use a single
> > command
> > to open all this files and I need to change a single parameter in the
> > files. It is too time consuming to open them individually
>
> > Thank you!
>
> > Regards,
> > Zhengquan
>
>         gvim
>         :cd ~/.build/Tom.Dick.Harry
>         :args **/Makefile
>         :argdo %s/\$(FOO)/$(BAR)/g | update
>         :q
>
> (untested, and assuming a bash or similar shell) will change "$(FOO)" to
> "$(BAR)" (as explicit strings in both cases, no substitution) in every
> "Makefile" in the directory "~/.build/Tom.Dick.Harry/" and below, down
> to 30 levels deep. Replace **/ by **255/ to search 255 levels deep (the
> maximum in Vim).
>
>         :help :args
>         :help starstar
>         :help :argdo
>
> Best regards,
> Tony.
> --
> Gravity is an unforgiving motherfucker.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

syntax-on highlights: unhappy with some defaults

reviol
In reply to this post by Andy Kittner

Hi!

This is about the "default" colour scheme for "syntax on". Overall, it  
is not bad. But some highlight features are too much for my taste. For  
example, the blanck space in a fortran code is by default filled with  
red. How can one undo this?

I tried to "interpret" such a blanck as "fortranTab" (which is not  
quite true) and tried then: "fortranTab gui=NONE".

But this did not work. Could I get another word from a wise guy?

Best Regards,
Walter

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

Tony Mechelynck
On 08/05/08 00:55, [hidden email] wrote:

> Hi!
>
> This is about the "default" colour scheme for "syntax on". Overall, it
> is not bad. But some highlight features are too much for my taste. For
> example, the blanck space in a fortran code is by default filled with
> red. How can one undo this?
>
> I tried to "interpret" such a blanck as "fortranTab" (which is not
> quite true) and tried then: "fortranTab gui=NONE".
>
> But this did not work. Could I get another word from a wise guy?
>
> Best Regards,
> Walter
Well, there might be a reason for it -- I knew Fortran in 1967 but I
haven't kept up with the later developments of the language. Maybe you
can have Vim interpret your Fortran sources according to a different
standard of the language, see":help fortran-syntax".

If that doesn't work, and assuming changing the background color is
still needed, you got to identify the highlight group name for that
region and change its colour. If that isn't enough, you might have to
either create a ~/.vim/after/syntax/fortran.vim or to copy
$VIMRUNTIME/syntax/fortran.vim to ~/.vim/syntax and modify it there
(don't modify it in place) in order to add a new syntax group.

Sooner or later you will want to write a user-written colorscheme -- you
don't need to mention in it the highlight groups for which the default
colours are OK for you.

I'm attaching my usual colourscheme -- drop it in $VIM/vimfiles/colors
(creating any not-yet-existent directory in the process) and change it
to your heart's liking. (It will probably not suit you as-is.)

Best regards,
Tony.
--
Violators can be fined, arrested or jailed for making ugly faces at a dog.
                [real standing law in Oklahoma, United States of America]

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---


almost-default.vim (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

Charles E Campbell Jr
In reply to this post by reviol

[hidden email] wrote:

>Hi!
>
>This is about the "default" colour scheme for "syntax on". Overall, it  
>is not bad. But some highlight features are too much for my taste. For  
>example, the blanck space in a fortran code is by default filled with  
>red. How can one undo this?
>
>I tried to "interpret" such a blanck as "fortranTab" (which is not  
>quite true) and tried then: "fortranTab gui=NONE".
>
>But this did not work. Could I get another word from a wise guy?
>  
>
First of all -- setting up a new unrelated topic in a thread is a good
way to have it not be seen.  Ie., don't use reply and the backspace key
on the subject; use "compose".

Now, for #2: have you read   :help fortran.vim ?  In particular, check
on some of the settings such as fortran_free_source .

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: recursively edit the files with the same name

Charles E Campbell Jr
In reply to this post by Tony Mechelynck

Tony Mechelynck wrote:

> <snip>
>
> :help :args
> :help starstar
> :help :argdo
>  
>
May I also suggest looking at

  :help netrw-starstar

If you have problems with it... there were some bug fixes/changes to
netrw's starstar support in v115; netrw is now up to v124 (released) /
v125k (astro-only).

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

Benjamin Fritz
In reply to this post by Charles E Campbell Jr

On 5/7/08, Charles E. Campbell, Jr. <[hidden email]> wrote:

>
>  [hidden email] wrote:
>
>
> >Hi!
>  >
>  >This is about the "default" colour scheme for "syntax on". Overall, it
>  >is not bad. But some highlight features are too much for my taste. For
>  >example, the blanck space in a fortran code is by default filled with
>  >red. How can one undo this?
>  >
>  >I tried to "interpret" such a blanck as "fortranTab" (which is not
>  >quite true) and tried then: "fortranTab gui=NONE".
>  >
>  >But this did not work. Could I get another word from a wise guy?
>  >
>  >
>
> First of all -- setting up a new unrelated topic in a thread is a good
>  way to have it not be seen.  Ie., don't use reply and the backspace key
>  on the subject; use "compose".
>
>  Now, for #2: have you read   :help fortran.vim ?  In particular, check
>  on some of the settings such as fortran_free_source .
>
>  Regards,
>  Chip Campbell
>

This can help with figuring out what the highlight group you need to change is:

http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

Charles E Campbell Jr

Benjamin Fritz wrote:

>On 5/7/08, Charles E. Campbell, Jr. <[hidden email]> wrote:
>  
>
>> [hidden email] wrote:
>>
>>
>>    
>>
>>>Hi!
>>>      
>>>
>> >
>> >This is about the "default" colour scheme for "syntax on". Overall, it
>> >is not bad. But some highlight features are too much for my taste. For
>> >example, the blanck space in a fortran code is by default filled with
>> >red. How can one undo this?
>> >
>> >I tried to "interpret" such a blanck as "fortranTab" (which is not
>> >quite true) and tried then: "fortranTab gui=NONE".
>> >
>> >But this did not work. Could I get another word from a wise guy?
>> >
>> >
>>
>>First of all -- setting up a new unrelated topic in a thread is a good
>> way to have it not be seen.  Ie., don't use reply and the backspace key
>> on the subject; use "compose".
>>
>> Now, for #2: have you read   :help fortran.vim ?  In particular, check
>> on some of the settings such as fortran_free_source .
>>
>> Regards,
>> Chip Campbell
>>
>>    
>>
>
>This can help with figuring out what the highlight group you need to change is:
>
>http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor
>  
>
Just in case I wasn't clear -- I suspect that what is being seen is
Error highlighting -- and, if I'm right, changing that group's
highlighting isn't what's needed.  Instead, I think the default Fortran
syntax setting is flagging his use of a blank as an Error.  Of course, I
could be wrong...

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

reviol
In reply to this post by Tony Mechelynck

Hi again!

And thanks for the response. Example: By default, the "parameter"

         fortranContinueMark

(the & symbol) is highlighted. What is the command to turn off the
highlight for this particular parameter?

Walter

Quoting Tony Mechelynck <[hidden email]>:

> On 08/05/08 00:55, [hidden email] wrote:
>> Hi!
>>
>> This is about the "default" colour scheme for "syntax on". Overall, it
>> is not bad. But some highlight features are too much for my taste. For
>> example, the blanck space in a fortran code is by default filled with
>> red. How can one undo this?
>>
>> I tried to "interpret" such a blanck as "fortranTab" (which is not
>> quite true) and tried then: "fortranTab gui=NONE".
>>
>> But this did not work. Could I get another word from a wise guy?
>>
>> Best Regards,
>> Walter
>
> Well, there might be a reason for it -- I knew Fortran in 1967 but I
> haven't kept up with the later developments of the language. Maybe you
> can have Vim interpret your Fortran sources according to a different
> standard of the language, see":help fortran-syntax".
>
> If that doesn't work, and assuming changing the background color is
> still needed, you got to identify the highlight group name for that
> region and change its colour. If that isn't enough, you might have to
> either create a ~/.vim/after/syntax/fortran.vim or to copy
> $VIMRUNTIME/syntax/fortran.vim to ~/.vim/syntax and modify it there
> (don't modify it in place) in order to add a new syntax group.
>
> Sooner or later you will want to write a user-written colorscheme -- you
> don't need to mention in it the highlight groups for which the default
> colours are OK for you.
>
> I'm attaching my usual colourscheme -- drop it in $VIM/vimfiles/colors
> (creating any not-yet-existent directory in the process) and change it
> to your heart's liking. (It will probably not suit you as-is.)
>
> Best regards,
> Tony.
> --
> Violators can be fined, arrested or jailed for making ugly faces at a dog.
> [real standing law in Oklahoma, United States of America]
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: syntax-on highlights: unhappy with some defaults

Charles E Campbell Jr


Thus wrote [hidden email] :
> And thanks for the response. Example: By default, the "parameter"
>
>          fortranContinueMark
>
> (the & symbol) is highlighted. What is the command to turn off the
> highlight for this particular parameter?
 ---------------------------------------------------------------------
May I suggest two plugins that I wrote:

hilinks.vim:

   http://mysite.verizon.net/astronaut/vim/index.html#HILINKS

This one provides the :HLT! command -- with it you'll get a syntax stack trace
and a highlighting stack trace as you move your cursor about. Thus, you'll be
able to identify what it is you want to change.

In your case you've already identified the parameter (fortranContinueMark).  You
can put in

.vim/after/fortran.vim  the line
hi link fortranContinueMark SomeHighlightingGroupNameHere  (where Some... could
be String, Comment, Statement, Special, etc).

The second plugin I wrote that may help:  hicolors.vim
You can get it from

      http://mysite.verizon.net/astronaut/vim/index.html#HICOLORS

With it:

   :he hicolors

It will then display a five-column list of highlighting groups displayed in
their own colors.  Leftclick on one, and you'll get help for that color group
(if there is help).  Rightclick on one, and a color editor appears where you
can modify the colors to whatever you wish.  Save the resulting colorscheme,
rename it as you wish, and move it to .vim/colors.  Put

   colors YourColorSchemeNameHere

in your <.vimrc>, then the next time you bring [g]vim up, your new colorscheme
will be active.

Regards,
Chip Campbell




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---