One of my most favorite special variables in OpenSCAD is $preview

This variable is True on preview (F5) and False on Render (F6). It allows you to work on complex assemblies without having to comment everything out just to render a single part for export!

$preview can also be combined with $fn to automatically increase fragment count for export

@janamarie Thank you for telling me/us about that variable. No more commenting out preview things in the future for me (unless I forget about it again).
@trilader Combine this knowledge with OpenSCADs templating engine by creating a "boilerplate" template, which adds this if-else clause for you :3
@janamarie Do you have a link to information/resources about that templating engine? A quick search only gave me some years old github links to repos from various people.

@trilader Sadly no, it is not documented /o\

But here is a templates template:

cat ~/.config/OpenSCAD/templates/bp.json

{
"key" : "!bp",
"content" : "$fn=100;\n\nmodule ^~^(){\n\tdifference(){\n\t\tunion(){\n\t\t}union(){\n\t\t}\n\t}\n}"
}

^~^ denotes where the cursor will land
"key" : "!bp" denotes the name shown in openscad, I used "!" so it always is the first entry

You can insert a template by pressing Alt+Insert

@janamarie do you have any experience with cadquery by any chance? If so, any thoughts you can give?
@vincentb Never tried it, looks interesting though!
@janamarie i know kicad uses it to generate 3d models and wanted to add a JST connector but it is still ony todo list haha