Loading ...
Sorry, an error occurred while loading the content.

Re: Newbie question: How to give a command over they current file and all other files in directory

Expand Messages
  • Tony Mechelynck
    ... From: Eric Leenman To: vim Sent: Wednesday, September 28, 2005 10:28 AM Subject: Newbie question: How to give a
    Message 1 of 2 , Sep 28, 2005
    • 0 Attachment
      ----- Original Message -----
      From: "Eric Leenman" <ELeenman@...>
      To: "vim" <vim@...>
      Sent: Wednesday, September 28, 2005 10:28 AM
      Subject: Newbie question: How to give a command over they current file and
      all other files in directory


      > Hi,
      >
      > If I have one file open in gVim, say file1.c,
      > how can I give a command in gVim which would apply to file1.c but also
      > to all other .c files in the directory which are not open in gVim?
      >
      > For Example to:
      > - rename everywhere global var gWriteFlag into gWrFlg
      > :%s/gWriteFlag/gWrFlg
      > - to remove all spaces at the end of lines
      > :%s= *$==
      >
      >
      > Rgds,
      > Eric

      " change to directory of current file
      :cd %:p:h
      " define new arguments list
      :args *.c
      " do something on all files in the list
      :argdo 1,$s/\<gWriteFlag\>/gWrFlg/g
      or
      :argdo 1,$s/\s*$//

      Note: for the first substitution, you will probably want to check for word
      boundaries (not replace BlogWriteFlaggingRoutine by BlogWrFlggingRoutine)
      and replace all matches, even several on a line (hence the g flag).

      see
      :help :args
      :help :argdo


      HTH,
      Tony.
    Your message has been successfully submitted and would be delivered to recipients shortly.