I know how to delete a part of text from cursor position to occurence of pattern, I mean d/<pattern>
. I am wondering how to delete a part of text before cursor position until occurrence of pattern which is before cursor position.
Being in position x in file:
>>>>
aaaa
===x
bbbb
<<<<
I want to delete
>>>>
aaaa
====
This is work if pattern is exists only once in file... and vim doesn't have a choice. However there is a problem with file like this:
>>>>
aaaa
====
bbbb
<<<<
foo
boo
>>>>
cccc
====
dddd
<<<<
You can search backwards using ?
. So to delete back until a pattern, use d?<pattern>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With