Reputation: 36166
What's the best, fastest way to delete anything till a previous word (even if it's not on the same line). Example:
(cursor is right before d
in dolor
)
Lorem Ipsum
dolor sit amet
I need to delete all spaces until the previous word and position cursor right after Ipsum
. Result should be:
Lorem Ipsumdolor sit amet
with cursor between m
and d
Upvotes: 1
Views: 700
Reputation: 8905
dge will ALMOST do it.
d
is the well-known delete operator.
ge
is the motion to go to the end of the previous word.
But it deletes one character too many. So either add that character back in, or use visual mode to select exactly what you want to delete.
vgeld
This will work across any number of lines, or within a single line.
I think if you have only 2 lines you care about though, that the other answers using J are better.
Upvotes: 2
Reputation: 20456
-Jx
-J
to join the second line to line above
x
to delete the space between the words Ipsum & dolor
Upvotes: 4
Reputation: 3375
You can use kJ
or beJ
when the cursor is before letter d
of dollar
k move up one line
J Join line below to current line
and
Lorem Ipsum
dolor sit amet
will become
Lorem Ipsum dolor sit amet
Upvotes: 4
Reputation: 11609
I am not sure whether it can be done in a single cmd. Here's what I know (4 keys):
In escape mode, use '=='
while you are on the dolor
line:
Lorem Ipsum
dolor sit amet
Now, press up
arrow, to go to the 1st line, and then Press 'A'
, and then a 'del'
Lorem Ipsumdolor sit amet
Upvotes: 0