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

49553RE: >> help with scripting vim

Expand Messages
  • Sean C. Hubbell
    Apr 22, 2004
    • 0 Attachment
      %s!192\.168\.1\.1!192\.168\.1\.2!g

      % - global
      s - substitute
      . needs to be escaped as it is a special character
      ! -just the delimiter I used
      g - all occurrences on the line

      I have a perl script that I wrote a while back that globs files in the
      current directory. I do not know if you have perl installed, but if you
      would like it I will send it to you (I will not send attachments to the
      list). The example usage is

      snr.pl OldPattern NewPattern File/s

      i.e.

      snr.pl "192\.168\.1\.1" "192\.168\.1\.2" *.c

      HTH,

      Sean

      -----Original Message-----
      From: lists@... [mailto:lists@...]
      Sent: Thursday, April 22, 2004 2:54 PM
      To: vim@...
      Subject: >> help with scripting vim


      Hello list,

      I am stuck trying to write a bash shell script that can edit a text file.
      I was hoping that someone could show me how to do this with vim from
      within a bash script.

      Here's what I need to do:

      open file test.txt with vim
      search for 192.168.1.1 and replace with 192.168.1.2
      save the file and exit vim


      Thanks,
      devin
    • Show all 9 messages in this topic