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

Answers on Questions (was: quick question

Expand Messages
  • Frans Grotepass
    ... Hi Chris and others, This is one of the first decent answers I ve seen on this list. I ve been using (g)Vim now for a number of years sporadically.
    Message 1 of 17 , Dec 1, 2005
    • 0 Attachment
      On Thursday 01 December 2005 17:30, Chris Allen wrote:
      > On 01/12/05, Chris Hudson <chudson@...> wrote:
      > > How would I replace every line in a file that starts with certain text,
      > > for example every line that begins with 22.
      >
      > The 'substitute' command. For example:
      >
      > %s/^22.*$/my replacement text/
      >
      > That would replace anywhere in the whole file (%) a string which
      > started (^) with 22 (22) and then continued on with anything (or even
      > nothing) (.*) to the end of the line ($). See also :help :s
      >
      > You can also delete any line starting with a certain string using the
      >
      > :global command, if you decide you'd rather do that. Something like:
      > :g/^22/ d
      >
      > HTH,
      > Chris Allen


      Hi Chris and others,

      This is one of the first decent answers I've seen on this list. I've been
      using (g)Vim now for a number of years sporadically. Recently I've changed
      jobs and I now have a development job in embedded linux, so I am using Vim
      more often now. The last few months I've made a concerted effort to improve
      my Vim skills. Using the Vim Regular expressions is obviously one of the
      powerful tools in the search/replace functions. They are explained in the
      help.

      This response is however a good example of how one can learn via example. Most
      of the answers on questions on this list is simply a post of the commandline
      and it is assumed that the person asking the question knows what the symbols
      mean in the search replace. Your response does however show exactly what each
      expression does and makes it easier for the reader helped by your response to
      achieve fluency in regular expressions faster.

      Best regards,

      Frans Grotepass
    Your message has been successfully submitted and would be delivered to recipients shortly.