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

replacement question

Expand Messages
  • Alessandro
    Hello, I m trying to remove lines in a file that have the word length . ... But this, as you probably know, leaves a blank line in place of the line that was
    Message 1 of 6 , Jan 1, 2006
    • 0 Attachment
      Hello,

      I'm trying to remove lines in a file that have the word "length".

      I did so like this:

      :%s/.*length.*//g

      But this, as you probably know, leaves a blank line in place of the line
      that was there before. I wold like to make it so that the lines is
      completely erased, as in all lines after that should go up one (like
      doing "dd" on each line that contains "length").

      Thank you,

      ~Ale
    • Ricardo SIGNES
      * Alessandro [2006-01-01T17:44:58] ... You want the command :g, which runs a command on each line that matches a pattern. ... -- rjbs
      Message 2 of 6 , Jan 1, 2006
      • 0 Attachment
        * Alessandro <a24@...> [2006-01-01T17:44:58]
        > I'm trying to remove lines in a file that have the word "length".
        >
        > I did so like this:
        >
        > :%s/.*length.*//g

        You want the command :g, which runs a command on each line that matches
        a pattern.

        :g/PATTERN/command

        So, you want:

        :g/.*length.*/d

        --
        rjbs
      • Bill McCarthy
        ... -- Best regards, Bill
        Message 3 of 6 , Jan 1, 2006
        • 0 Attachment
          On Sun 1-Jan-06 4:44pm -0600, Alessandro wrote:

          > I'm trying to remove lines in a file that have the word "length".
          >
          > I did so like this:
          >
          > :%s/.*length.*//g

          Apparently you don't care whether "length" is a "word" so:

          :g/length/d

          --
          Best regards,
          Bill
        • Mark Woodward
          ... -- Mark
          Message 4 of 6 , Jan 1, 2006
          • 0 Attachment
            Alessandro said the following on 2/01/2006 9:44 AM:

            >Hello,
            >
            >I'm trying to remove lines in a file that have the word "length".
            >
            >I did so like this:
            >
            >:%s/.*length.*//g
            >
            >But this, as you probably know, leaves a blank line in place of the line
            >that was there before. I wold like to make it so that the lines is
            >completely erased, as in all lines after that should go up one (like
            >doing "dd" on each line that contains "length").
            >
            >Thank you,
            >
            >~Ale
            >
            >
            you could just use:
            :g/length/d


            --
            Mark
          • A. J. Mechelynck
            ... Assuming you want to delete the length and width of the room (where length is a word) but not the line will be lengthened (where it isn t), you could use
            Message 5 of 6 , Jan 1, 2006
            • 0 Attachment
              Alessandro wrote:
              > Hello,
              >
              > I'm trying to remove lines in a file that have the word "length".
              >
              > I did so like this:
              >
              > :%s/.*length.*//g
              >
              > But this, as you probably know, leaves a blank line in place of the line
              > that was there before. I wold like to make it so that the lines is
              > completely erased, as in all lines after that should go up one (like
              > doing "dd" on each line that contains "length").
              >
              > Thank you,
              >
              > ~Ale
              >
              >
              >
              >

              Assuming you want to delete

              the length and width of the room

              (where "length" is a word) but not

              the line will be lengthened

              (where it isn't), you could use

              :g/\<length\>/d

              see
              :help :g
              :help :d
              :help pattern

              HTH,
              Tony
            • Ted Arnold
              ... I find it amusing that you weenies are so stupid. Here, Alessandro, cannot figure out a simple task. What an idiot. Sheesh. I see this idiocy is typical
              Message 6 of 6 , Jan 1, 2006
              • 0 Attachment
                Alessandro wrote:
                > Hello,
                >
                > I'm trying to remove lines in a file that have the word "length".
                >
                > I did so like this:
                >
                > :%s/.*length.*//g
                >
                > But this, as you probably know, leaves a blank line in place of the line
                > that was there before. I wold like to make it so that the lines is
                > completely erased, as in all lines after that should go up one (like
                > doing "dd" on each line that contains "length").
                >
                > Thank you,
                >
                > ~Ale
                >
                >

                I find it amusing that you weenies are so stupid.

                Here, Alessandro, cannot figure out a simple task. What an idiot. Sheesh.

                I see this idiocy is typical among those asking questions.

                What helpless idiots you vim people are. Stupid-wise, you're at the bottom.
              Your message has been successfully submitted and would be delivered to recipients shortly.