> I need to replace all occurrences in a LaTeX-file of 
> 
> \textcolor{LRed}{bar}
> 
> with:
> 
> bar
> 
> That means I need only to remove this exact LaTeX code around "bar". I don't 
> know what to escape in my grep pattern. I tried nearly everything to escape : 
> ( ) [ ] \ ...
> 
> But nothing seems to work. Is there somewhere a list of special characters, 
> which I have to escape in a grep pattern?

Yes, you can find it by typing `:help magic`.  "magic" is a setting which tells 
Vim which characters have special meaning in a regex.

One way to figure out the pattern is by trying to search for it (by typing 
`/pattern`) because it uses the same regex rules.


> My grep is as follows (without any escapes) : 
> 
> :%s@\textcolor{LRed}{([^}]+)}@\1@g
> 
> What I have to escape here? 

This should work:

%s@\\textcolor{LRed}{\(\w\+\)}@\1@g

Or this, which specifies a "very magic" pattern:

%s@\v\\textcolor\{LRed\}\{(\w+)\}@\1@g

Yours,
Andrew Stewart

-- 
-- 
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_mac+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to