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

Search in VI (VIM) for a string, then delete to end of line.

Expand Messages
  • Nerdio
    I have a requirement which I am sure I can do in vi (plenty of other solutions I am sure), and this is it. I have a file that looks like this 1234 Some Text
    Message 1 of 6 , May 7, 2014
    • 0 Attachment
      I have a requirement which I am sure I can do in vi (plenty of other solutions I am sure), and this is it.

      I have a file that looks like this

      1234 Some Text HERE rest of line
      1235 Some Other Text HERE rest of line

      What I want to do is delete text from, and including the word HERE to the end of the line, leaving me with this;

      1234 Some Text
      1235 Some Other Text

      I have done search and replace things in vi, but am not sure how to do a search then run a command.

      Any help, as always is greatly appreciated.

      Thanks in anticipation

      (This has been posted elsewhere, so sorry for duplication)

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Christian Brabandt
      Hi Nerdio! ... Search and replace sounds like the correct solution here. What is wrong with it? Best, Christian -- Viele Menschen fliehen in die Diktatur, weil
      Message 2 of 6 , May 7, 2014
      • 0 Attachment
        Hi Nerdio!

        On Mi, 07 Mai 2014, Nerdio wrote:

        > I have a requirement which I am sure I can do in vi (plenty of other solutions I am sure), and this is it.
        >
        > I have a file that looks like this
        >
        > 1234 Some Text HERE rest of line
        > 1235 Some Other Text HERE rest of line
        >
        > What I want to do is delete text from, and including the word HERE to the end of the line, leaving me with this;
        >
        > 1234 Some Text
        > 1235 Some Other Text
        >
        > I have done search and replace things in vi, but am not sure how to do a search then run a command.

        Search and replace sounds like the correct solution here. What is wrong
        with it?

        Best,
        Christian
        --
        Viele Menschen fliehen in die Diktatur, weil es guter Nerven bedarf,
        die Demokratie zu ertragen.
        -- Hans Habe

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Tim Chase
        ... Since your command merely consists of deleting to the end of the line, you can search for your string, followed by anything, and it ... (which will prompt
        Message 3 of 6 , May 7, 2014
        • 0 Attachment
          On 2014-05-07 09:07, Nerdio wrote:
          > I have a requirement which I am sure I can do in vi (plenty of
          > other solutions I am sure), and this is it.
          >
          > I have a file that looks like this
          >
          > 1234 Some Text HERE rest of line
          > 1235 Some Other Text HERE rest of line
          >
          > What I want to do is delete text from, and including the word HERE
          > to the end of the line, leaving me with this;
          >
          > 1234 Some Text
          > 1235 Some Other Text
          >
          > I have done search and replace things in vi, but am not sure how to
          > do a search then run a command.

          Since your command merely consists of deleting to the end of the
          line, you can search for your string, followed by anything, and it
          will delete:

          :%s/HERE.*

          or, if you want to make sure:

          :%s/HERE.*//c

          (which will prompt you for each one).

          Additionally, it looks like you have some whitespace before your
          "HERE", so you might actually want

          :%s/\s\+HERE.*

          which will clean that up as well.

          -tim
        • Daniel Moore
          Is it possible to tell gvim not to try to do OLE registration on startup apart from recompiling? I am on a client laptop with a particularly aggressive
          Message 4 of 6 , May 7, 2014
          • 0 Attachment
            Is it possible to tell gvim not to try to do OLE registration on startup apart from recompiling? I am on a client laptop with a particularly aggressive antivirus which appears to be blocking all registry modifications so I am getting the registration dialogue box every time I open gvim. Besides being a little annoying I have unconfirmed suspicions that it is inhibiting gvim from working as a git difftool.

            Daniel

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Daniel Moore
            Would this solve your problem? ... On May 7, 2014, at 11:07 AM, Nerdio wrote: I have a requirement which I am sure I can do in vi
            Message 5 of 6 , May 7, 2014
            • 0 Attachment
              Would this solve your problem?

              :%s/HERE.*$//gc



              On May 7, 2014, at 11:07 AM, Nerdio <logistexsteve@...> wrote:

              I have a requirement which I am sure I can do in vi (plenty of other solutions I am sure), and this is it.

              I have a file that looks like this

              1234 Some Text HERE rest of line
              1235 Some Other Text HERE rest of line

              What I want to do is delete text from, and including the word HERE to the end of the line, leaving me with this;

              1234 Some Text
              1235 Some Other Text

              I have done search and replace things in vi, but am not sure how to do a search then run a command.

              Any help, as always is greatly appreciated.

              Thanks in anticipation

              (This has been posted elsewhere, so sorry for duplication)

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • Gary Johnson
              ... I m no expert on OLE, but from this excerpt from :help -unregister , it appears the answer is no. If you want to have (several) Vim sessions open that
              Message 6 of 6 , May 7, 2014
              • 0 Attachment
                On 2014-05-07, Daniel Moore wrote:
                > Is it possible to tell gvim not to try to do OLE registration on
                > startup apart from recompiling? I am on a client laptop with a
                > particularly aggressive antivirus which appears to be blocking all
                > registry modifications so I am getting the registration dialogue
                > box every time I open gvim. Besides being a little annoying I have
                > unconfirmed suspicions that it is inhibiting gvim from working as
                > a git difftool.

                I'm no expert on OLE, but from this excerpt from ":help
                -unregister", it appears the answer is no.

                If you want to have (several) Vim sessions open that should not
                react to OLE commands, use the non-OLE version, and put it in a
                different directory. The OLE version should then be put in a
                directory that is not in your normal path, so that typing "gvim"
                will start the non-OLE version.

                Also, if you wish to ask a new question, please start a new thread
                rather than replying to an existing one, and give it a meaningful
                subject.

                Regards,
                Gary

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              Your message has been successfully submitted and would be delivered to recipients shortly.