How to delete to start of pattern on another line?
I would like to know if it is possible to delete till the start of a pattern on another line.
p.e.
- good morning |
- empty line
- empty line
- empty line
- ....
- empty line
- hello world
Is it possible to delete from cursor "|" in line 1 till "world in line 7? (remaini开发者_运维问答ng in normal mode)
I do this often. Normally I use "dd" to delete all lines between line 1 and line 7 and then delete to word "dfw" but this is quit difficult if I'm on line 347 and my text is on 381. I have to count the lines between them and often I delete one line too much.
Rather than using dd
(which deletes a single line), you can use the more general d
command as follows (^ is your cursor)
^The quick
brown fox
jumped over
the lazy
dog
Type d/the
then press enter. It will delete from the cursor to the beginning of the first search match, leaving you with
the lazy
dog
You can search for "world":
d/world<Enter>
精彩评论