15

I know that I can delete from the cursor till and including the first occurence of a character x with dfx. This only works on one line. How can I delete from the current cursor position till the first occurence of x when x is not in the same line?

E.g., if the cursor is after the first space in

yada yada yada
yada yada yada x

and I type dfx the result needs to be:

yada

user2609980
  • 729
  • 1
  • 6
  • 10

2 Answers2

25

Use / for forward search:

d/x<CR>

and ? for backward search:

d?x<CR>
romainl
  • 40,486
  • 5
  • 85
  • 117
12

I wanted to comment on romainl's answer, but I don't have enough reputation to do so yet!

Although it needs one more keystroke, I find it useful to do v/x<CR>d to see the portion that is being removed.

  • 2
    That's a valid answer. No need to put it in a comment. We're only talking about one piece of software (with its variations), so you don't necessarily need to get fancy to have a valid answer-worthy answer. – Wildcard Oct 23 '15 at 07:17
  • @ErwinRooijakkers you should select this answer if this is what you'll now use. – Paul Evans Oct 23 '15 at 16:03
  • @PaulEvans I don't agree. Although this answer has more practical value for me, I think that the accepted answer provides a better answer to the question asked (since it does exactly what is requested -- I did not ask to see the text highlighted first). – user2609980 Oct 23 '15 at 19:40