Sometimes only 10 lines of 100 are relevant to the question/answer, the other 90 are setup.
Is there a way to hide 90 those in lines in the answer?
The way to do this is just to include the 10 lines like you normally would.
Then in the Stack Snippet you place the full code. So the 10 lines will appear twice in the markup. One time before the snippet starts, and one time in the snippet.
Then make sure to check mark the box to hide the snippet by default, as shown below :
For a working example of this, see my answer that does just this here