Reputation: 9134
Say I have these lines in Vim:
void CSSdescramble(unsigned char *sec,unsigned char *key) {
unsigned int t1,t2,t3,t4,t5,t6;
And say the cursor is somewhere in the middle of the second line. How can I delete everything on that line except for the two leading spaces?
I can do it with ^d$
, but I'm wondering if there's a more efficient way.
Upvotes: 2
Views: 72
Reputation: 195029
golf a bit:
try with single S
(big S in normal mode), if you don't care switching to insert
mode.
otherwise, use others answer ^D
etc.
Upvotes: 1
Reputation: 1949
As @user1281385 pointed out, you can use D
— which deletes from the cursor to the end of the line — to save a keystroke.
If you want to keep the whitespace at the beginning of the line, I don’t think there’s a way around ^
.
Upvotes: 0
Reputation: 11761
I guess, the easiest way is to use cc
, if you wish to type something new instead of deleted line. Otherwise ^D
.
Upvotes: 4
Reputation: 122364
C
(shift-c) has the same effect as d$a
, deleting the rest of the line and putting you into insert mode (the question asked about ^d$a
when I first answered it). Or D
does the same as d$
without the a
.
Upvotes: 1