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

How to delete everything before the cursor until the beginning of the line?

Expand Messages
  • Peng Yu
    D deletes everything after the cursor until the end of the line. Is there a command that delete everything before the cursor until the beginning of the line?
    Message 1 of 7 , Jan 1, 2010
    • 0 Attachment
      'D' deletes everything after the cursor until the end of the line. Is
      there a command that delete everything before the cursor until the
      beginning of the line?

      --
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Chris Jones
      ... v0d is what I do.. three key presses. Surely there s a better way? CJ -- You received this message from the vim_use maillist. For more information, visit
      Message 2 of 7 , Jan 1, 2010
      • 0 Attachment
        On Fri, Jan 01, 2010 at 06:04:46PM EST, Peng Yu wrote:

        > 'D' deletes everything after the cursor until the end of the line. Is
        > there a command that delete everything before the cursor until the
        > beginning of the line?

        v0d is what I do.. three key presses. Surely there's a better way?

        CJ

        --
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
      • Marc Weber
        Another way: use in insert mode. You know about a and i to enter insert mode.. Marc Weber -- You received this message from the vim_use maillist. For
        Message 3 of 7 , Jan 1, 2010
        • 0 Attachment
          Another way:

          use <c-u> in insert mode. You know about a and i to enter insert mode..

          Marc Weber

          --
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
        • Tim Chase
          ... d0 should do the trick. No need to go visual. -tim -- You received this message from the vim_use maillist. For more information, visit
          Message 4 of 7 , Jan 1, 2010
          • 0 Attachment
            Chris Jones wrote:
            > On Fri, Jan 01, 2010 at 06:04:46PM EST, Peng Yu wrote:
            >
            >> 'D' deletes everything after the cursor until the end of the line. Is
            >> there a command that delete everything before the cursor until the
            >> beginning of the line?
            >
            > v0d is what I do.. three key presses. Surely there's a better way?


            d0

            should do the trick. No need to go visual.

            -tim


            --
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
          • Tim Chase
            ... Just a word of caution, this requires that backspace include start (which it often does, but can sting you of if you expect it and it *isn t* set).
            Message 5 of 7 , Jan 1, 2010
            • 0 Attachment
              Marc Weber wrote:
              > Another way:
              >
              > use <c-u> in insert mode. You know about a and i to enter insert mode..

              Just a word of caution, this requires that 'backspace' include
              "start" (which it often does, but can sting you of if you expect
              it and it *isn't* set).

              -tim


              --
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
            • Chris Jones
              ... dw, d$, dG, d{, dgg, etc. IOW, d +cursor movement.. what was I thinking. CJ -- You received this message from the vim_use maillist. For more
              Message 6 of 7 , Jan 1, 2010
              • 0 Attachment
                On Fri, Jan 01, 2010 at 06:40:24PM EST, Tim Chase wrote:
                > Chris Jones wrote:
                > > On Fri, Jan 01, 2010 at 06:04:46PM EST, Peng Yu wrote:

                > >> 'D' deletes everything after the cursor until the end of the line. Is
                > >> there a command that delete everything before the cursor until the
                > >> beginning of the line?
                > >
                > > v0d is what I do.. three key presses. Surely there's a better way?
                >
                >
                > d0
                >
                > should do the trick. No need to go visual.

                :-)

                dw, d$, dG, d{, dgg, etc. IOW, 'd'+cursor movement.. what was I
                thinking.

                CJ

                --
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
              • Tony Mechelynck
                ... There is a difference though: v0d deletes everything from the start of the line to the cursor location _included_ (v highlights the cursor character, then
                Message 7 of 7 , Mar 6, 2010
                • 0 Attachment
                  On 02/01/10 02:07, Chris Jones wrote:
                  > On Fri, Jan 01, 2010 at 06:40:24PM EST, Tim Chase wrote:
                  >> Chris Jones wrote:
                  >>> On Fri, Jan 01, 2010 at 06:04:46PM EST, Peng Yu wrote:
                  >
                  >>>> 'D' deletes everything after the cursor until the end of the line. Is
                  >>>> there a command that delete everything before the cursor until the
                  >>>> beginning of the line?
                  >>>
                  >>> v0d is what I do.. three key presses. Surely there's a better way?
                  >>
                  >>
                  >> d0
                  >>
                  >> should do the trick. No need to go visual.
                  >
                  > :-)
                  >
                  > dw, d$, dG, d{, dgg, etc. IOW, 'd'+cursor movement.. what was I
                  > thinking.
                  >
                  > CJ
                  >

                  There is a difference though: v0d deletes everything from the start of
                  the line to the cursor location _included_ (v highlights the cursor
                  character, then 0 extends the visual selection to the start of the line,
                  keeping the former cursor location highlighted, and finally d deletes
                  the selection). With d0, the character under the cursor is not deleted,
                  because 0 is an "exclusive" motion.

                  Best regards,
                  Tony.
                  --
                  "There are two ways of disliking poetry; one way is to dislike it, the
                  other is to read Pope."
                  -- Oscar Wilde

                  --
                  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
                Your message has been successfully submitted and would be delivered to recipients shortly.