0x7FFFFFFF
0x7FFFFFFF

Reputation: 1

How to search for \emph{.} and replace it with . in Vim?

I want to search for e.g.

\emph{word}

and replace it

with

word

So, I want to delete the surrounding \emph{}.

How can I do this using Vim?

Upvotes: 0

Views: 120

Answers (3)

ZyX
ZyX

Reputation: 53654

If word can contain nested subgroups (like in \emph{Do {\bf something} now} which is valid) you will have to use (in normal mode)

qaqqa/\\emph<CR>dt{ds{@aq@a

This assumes that you have surround.vim installed.

Upvotes: 1

Anomie
Anomie

Reputation: 94834

Try :%s/\\emph{\([^}]*\)}/\1/g

Upvotes: 5

David Amey
David Amey

Reputation: 1411

Have a look here: Vim searches

You probably want something like :%s/\\emph{\([^}]+\)}/\1/g

Upvotes: 2

Related Questions