7

If I am in the middle of a line, how to I cut to the beginning/end of a line? (is copy different)

If I am in the middle of a line, how do I paste over to the beg/end of the line? (is pasting w/o copying over the text much different?)

thanks allot!

codecompleting
  • 9,251
  • 13
  • 61
  • 102

1 Answers1

16

As Yoda said:

  1. d$ cuts to the end of the line
  2. d0 cuts to the beginning
  3. d^ cuts to first non-whitespace character

To paste over the 'head' of the line:

v^p

or

v0p

To make it remember the default register, you could use the _ unnamed register:

v$"_p

Note that in that case, the overwritten text is 'forgotten' instead of yanked. (By default replacing a visual selection effectively yanks the overwritten text, so you can put it somewhere else)

sehe
  • 374,641
  • 47
  • 450
  • 633
  • @yoda: well, only if that's not _your_ upvote :) Otherwise, it's just a guess – sehe Oct 14 '11 at 15:41
  • well, that is mine... should I take it away? ;) – abcd Oct 14 '11 at 15:42
  • ok it is deleting the white space at the beginning of the line which I don't want (like tabbing etc) – codecompleting Oct 14 '11 at 15:54
  • @codecompleting: not if you use the correct variant (choose `0` (include whitespace) or `^` (only till first non-whitespace character of the line)) **Edit** Huh - I just noticed that the post didn't say `^` but `$` :) sry. Updated answer now – sehe Oct 14 '11 at 16:22
  • edited the comment to add `dG` to cut to end of file. – luca76 Jan 15 '19 at 13:23