0

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

turn down\
turn off\
turn on\
\pard\pardeftab720\ri-6\sl-660\qc\partightenfactor0
\f0\b\fs32 \cf0 U\
\pard\pardeftab720\ri-6\sl-240\qj\partightenfactor0
\f1\b0\fs21 \cf0 up and down\
used to do sth.\
\pard\pardeftab720\ri-6\sl-660\qc\partightenfactor0
\f0\b\fs32 \cf0 W\
\pard\pardeftab720\ri-6\sl-240\qj\partightenfactor0
\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.

:g/^\/dd

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.

0

1 Answer 1

3

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

:global/^\\/delete

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, privacy policy and cookie policy

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