[Tex/LaTex] How to use TikZ in Lyx

lyx

How do you use TikZ efficiently in Lyx?
I understand I have to go to Insert->Tex code, which opens a box where I can type actual Tex code. But it's really difficult, there is no indentation, everything I type is in one color only. (Note: I'm using Lyx on Mac)
Is there any easier way to do this?

Best Answer

Write your tikzpicture in a separate plain text file, then include it in your LyX document, using the menu item Insert | File | Child Document.

You have to make sure that you use the Include type: Input here.

enter image description here