In Lyx how do I find and replace words with latex code (ERT)?
-
possible duplicate of Lyx customized view of command– Hendrik VogtMar 16, 2011 at 17:01
-
1) close lyx 2) open proper TeX IDE? But seriously, once you start hitting up against these limitations in LyX, it might be time to join the dark side...– SeamusMar 16, 2011 at 17:07
-
@Seamus You might be right, before I give up I thought I'd see if there's a simple solution I'm missing. You think Lyx developers would implement that, it seems kind of essential to me.– denilwMar 16, 2011 at 17:42
-
@Hendrik I don't seen how this question is related to that one.– denilwMar 16, 2011 at 17:45
-
I'm trying to do a simple find and replace, but instead of replacing a word with another word I want to replace a word with ERT or a combination of letters and ERTs.– denilwMar 16, 2011 at 17:46
2 Answers
I don't think there is a way to do that in LyX 1.6, but in LyX 2.0, which is supposed to be released pretty soon, and which is currently available as a release candidate version, this is very easy with "Advanced search". You can pretty much search for any formatted text or even math, and replace them with anything else.
-
+1 Thank you for the response. Say I'm trying to replace the word DNA with the LaTeX code \gls{DNA} for it's glossary entry. I'm using the version 2 pre-release candidate and I can confirm this works. If I try and do the reverse though it does not work.– denilwMar 18, 2011 at 16:31
-
It seems that you have to go the settings tab on the advanced search dialog, and uncheck "ignore format". Mar 18, 2011 at 19:22
You can do this with sed
for Lyx 1.6 files. If you create a Lyx file in.lyx
with the text:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Then run (Unix shell syntax, multiline command):
<in.lyx >out.lyx sed 's/voluptate/\
\begin_inset ERT\
status open\
\
\begin_layout Plain Layout\
\
voluptate\
\end_layout\
\
\end_inset\
/'
The file out.lyx will show in Lyx with "voluptate" in an ERT box.