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

Re: Search replace and rename in a directory structure

Expand Messages
  • Benji Fisher
    ... As a general rule, if you are trying to debug an :execute line, try ... w .chngd and .vhd . This has the effect of inserting a space between the two
    Message 1 of 2 , Jun 30, 2001
    • 0 Attachment
      hemant wrote:
      >
      > I am trying to change the do a search replace for a pattern which is same as
      > the file name for the pattern in a directory structure. Now i have made one
      > script which I will source everytime on command line using vim command line
      > arguments and that will ask me for the new name search replace the pattern
      > which i input and create a new file . My problem is whatever i input Vim
      > appends a space to it and search replaces it which i dont want also when it
      > creates a new file it it puts a space between the ".extension " and my input
      > pattern . Attached is my script. what I am doing wrong ?? ..I am using Vim
      > 5.7 MS-Windows 32 bit console version for this on Winnt4.0 .
      >
      > Regards ....Hemant
      >
      > ----------Cut here-------------------------
      > let chngd=input('Input the new entity name: ')
      > let curr=expand("%:r:t")
      > exec 'w ' .chngd '.vhd'
      > exec '%s/'.curr '/' .chngd
      > exec 'wq'
      > ----------Cut here-------------------------

      As a general rule, if you are trying to debug an :execute line, try
      :echo'ing the same line. Here the problem is that (in both lines) you give
      :execute two arguments. In the first line, the two arguments are
      'w ' .chngd and '.vhd'. This has the effect of inserting a space between
      the two arguments. Pass one argument instead: 'w ' . chngd . '.vhd' (Note
      the extra "."!). Similarly, add a "." to the second :execute line.

      HTH --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.