Here is (part of) a file that I am working on

turn down\
turn off\
turn on\
\f0\b\fs32 \cf0 U\
\f1\b0\fs21 \cf0 up and down\
used to do sth.\
\f0\b\fs32 \cf0 W\
\F1\b0\fs21 \cf0 wait for\
wake up\
work out\
worry about\
would like\
write down\
write to\

I would like to delete all lines that start with a \, but I am not sure how to go about it. I searched online but still there seems to be some piece missing. I tried to use regular expression.


But it doesn't work. I think I need to double quote the patten, but it still doesn't work. Vim replied with an error of pattern not found.


1 Answer 1


You need to escape the backslash with another backslash. The below will work.


which can be abbreviated to :g/^\\/d.

Note that dd as you originally had is a Normal mode command, while :global takes an Ex command after the pattern. You can use :normal[!] to enter a Normal command, but in this case the equivalent Ex command :delete is shorter and more idiomatic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.