Re:Bill Joy's greatest gift to man – the vi editor (2003)
by tgb on Wednesday May 06, 2020 @01:57PM
(#23094218)
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).
[ Parent
| on HN ]
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by leephillips on Wednesday May 06, 2020 @02:29PM
(#23094597)
daw 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.
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by tgb on Wednesday May 06, 2020 @08:03PM
(#23098012)
Good catch, I meant dap.
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by pletnes on Wednesday May 06, 2020 @02:06PM
(#23094316)
If you use relative line numbers, 5dd makes total sense.
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by tgb on Wednesday May 06, 2020 @02:14PM
(#23094428)
I 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.
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by lenkite on Saturday May 09, 2020 @02:28AM
(#23122748)
You 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.
Re:Bill Joy's greatest gift to man – the vi editor (2003)
by ecnahc515 on Wednesday May 06, 2020 @04:03PM
(#23095631)
Also to add to this, dt/pattern_string_here is really handy for deleting until the occurrence of some pattern.