5 ms·
I've always thought that doing 5dd and such was a bad demonstration of Vi(m) since I never know how many lines to delete. I'll just dd multiple times. More powe
by tgb 6y ago
I've always thought that doing 5dd and such was a bad demonstration of Vi(m) since I never know how many lines to delete. I'll just dd multiple times. More powerful vim commands are like daw (delete all of a paragraph), di) (delete inside of a set of parentheses), and dtX (delete until the character X).
- gen220 6y agoMy shorthand when I don’t know the number of lines is dj followed by a bunch of .’s :)
- pletnes 6y agoIf you use relative line numbers, 5dd makes total sense.
- tgb 6y agoI tried this for a while but it never clicked for me. I prefer using semantically-meaningful groupings like paragraphs or parentheses, it just seems nicer. And relative line numbers wouldn't make, say, 5dw any easier to count.
- lenkite 6y agoYou can use: df<char> to delete forward (including char), dt<char> to delete forward until char. (excluding char) d/<search><Enter> to delete until search pattern is found In case you wish to type immediately after deleting, replace 'd' with 'c' in the above.
- leephillips 6y agodaw deletes the word you are in (delete a word). But dap deletes a paragraph. And you can tell vi what you mean by "word" and "paragraph" (I think) in your settings file.
- tgb 6y agoGood catch, I meant dap.
- ecnahc515 6y agoAlso to add to this, dt/pattern_string_here is really handy for deleting until the occurrence of some pattern.
- mikelward 6y agoI prefer Vim's visual mode (Shift+V) for that. But yes, `dap` and friends are options too.