19

is there anyway to delete every character on the same line as a cursor, all the way up to the cursor? for instance, I might have a line of code that looks like the following:

foo = [cursor]             Bar.new

If my cursor is at the place holder above, is it possible to delete every whitespace character (without using regex?) so that Bar.new is placed at the cursor?

randombits
  • 47,058
  • 76
  • 251
  • 433
  • 4
    You're asking two separate questions... Do you want to delete whitespace leading to the cursor, or whitespace starting from your cursor up to the next non-whitespace character? – Jason Down Sep 24 '10 at 16:38
  • 1
    it should've read *from my cursor up to the start of the next word*, I think – sharat87 Sep 27 '10 at 15:02

4 Answers4

47

d w

Shimmy Hacked
  • 459
  • 5
  • 10
Neall
  • 26,428
  • 5
  • 49
  • 48
9

Based on your example, Neall's answer is correct. However, based on your initial question,

is there anyway to delete every character on the same line as a cursor, all the way up to the cursor?

you would type d 0

Actually, you're asking a third question in your title... delete all whitespace characters up to the cursor. That one I'm not sure how to do without regex. d g e would remove all the whitespace characters leading backwards until a non-whitespace, but it also deletes the first non-whitespace character.

Shimmy Hacked
  • 459
  • 5
  • 10
Jason Down
  • 21,731
  • 12
  • 83
  • 117
  • Not quite as neat, since you need to know the character you're deleting to, but deleting back to the = could be accomplished with `dT=`. **D** elete backwards-' **T** il **=** – dash-tom-bang Sep 24 '10 at 23:20
9

Not quite what you want, but perhaps d i w would help - in the example above, it would delete all the whitespace between the = and the Bar. Perhaps c i w space would give you the result you are looking for?

Shimmy Hacked
  • 459
  • 5
  • 10
zigdon
  • 14,573
  • 6
  • 35
  • 54
7

d t B

Will delete any character up to, but not including the 'B'

Shimmy Hacked
  • 459
  • 5
  • 10
jinfield
  • 312
  • 1
  • 2