Sunday, April 1, 2018

Search & replace with grep

Hello all!


I switched from Mac BBEdit to vim and need help with a grep pattern. I am still a beginner and putting up a VIM cheat file in LATEX for all vim-commands, which are part of my "repertoire". My search pattern is following, and there are many of them in my file:

Search:

\begin{center}
\textcolor{mygray}{\large w}
\end{center}

Replace:

\vimcode{w}

My try was the following:

:s/\begin{center}\n\(\s\+\)\textcolor{mygray}{\large \([^}]\+\)}\s+\end{center}\s+/$1\vimcode{$2}/g

Do I have to escape all \begin with \\begin ? This would be cumbersome and a reason to give up VIM. Already to escape the capturing parenthesis \( \) you have to get used to.

Is there a possibility to visual select some lines, to edit them in the search dialogue? Would it be possible, to put visual selected lines into the search dialogue with all special signs escaped automatically?


Thank you in advance


marek

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: