Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This behavior is consistent across all environments where I have used Vim (Cygwin, Putty, VC, xterm & co). I realize that it has something to do with the way input is read and the representaion of , but I'm not sure exactly why the key combination d + deletes two lines of text. Care to shed some light on this matter?

share|improve this question
    
If you had told us what you expect instead, we could better correct your misunderstanding. –  Ingo Karkat Apr 3 '13 at 13:54
    
I'd like to stick up for the OP - it's not obvious to me why it's two lines... rather than just the single character of D+left and D+right –  Joe May 5 '13 at 9:37
    
@Joe, thanks, but it's not a good question and kinda does deserve a couple of down votes. The answer depends on design choice as much as anything else.. I was more confused about why arrow keys behave differently on some terminals than why "d-down" deletes two lines. Perhaps I'll ask/answer the "real question" properly some time in the future. –  Ярослав Рахматуллин May 5 '13 at 10:27

3 Answers 3

up vote 4 down vote accepted

D and a cursor movement, deletes in that direction. It's just a standard binding.

D with H, J, K, L works the same way as the arrow keys.

share|improve this answer
    
Exactly. d + down deletes two lines because that is how vim is supposed to work. –  cpast Apr 3 '13 at 13:52
1  
Yes, silly confusion, it makes perfect sense. Let's contemplate the validity of the expression "There are no stupid questions ..." –  Ярослав Рахматуллин Apr 3 '13 at 15:03
1  
It's actually inconsistent - D+left and D+right delete one character, whereas D+up and D+down delete two lines. So no, it's not a stupid question. –  icabod Apr 4 '13 at 8:32

dd and :d deletes the current line, and d in visual mode deletes the highlighted text. When you move down a line holding d, you may be highlighting both lines, which then deletes them due to how VIm handles the d button press.

share|improve this answer

That behavior is consistent across systems because it is perfectly normal. What in all hell are you expecting dj or d<down> to do?

d is an "operator pending command": after it is pressed, Vim waits for a motion to apply the command to. Since you give it the <down> motion, d<down> deletes the current line and the line below.

share|improve this answer
1  
I could expect a number of things. None of them are naturally associated with hell. –  Ярослав Рахматуллин Apr 3 '13 at 15:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.