"Which" or "what" or ... when referring to a main clause?
There are many answered questions that address the usage of "which" and "what" on this site—many of them marked as duplicates—and there is even a specific tag for this topic. But I could not find any answer for the following question:
Should I use "which" or "what" or something else if I want to express
A does B which/what causes C.
Therein, "which/what" (the "which" or the "what") should not refer to B but to the act of A doing B (i.e. the predicate of the main clause).
For example see these alternatives:
Bob writes on the blackboard which causes a screeching noise.
Bob writes on the blackboard what causes a screeching noise.
Please note: The noise is caused by the writing not by the blackboard.
Side question: Would the use of a comma be appropriate here?
There is a closely related question, "Do we use “which” or “that” when referring to the preceding main clause as a whole?", that aims on "which" versus "that" as the alternatives and is answered in favor of "which". But maybe "what" would be the better choice here.
You need to use which. And you need a comma, otherwise the which may be interpreted as introducing a defining or restrictive relative clause with blackboard as its antecedent:
- Bob writes on the blackboard, which causes a screeching noise.
Swan in Practical English Usage (p495) has a section in relatives with the title: 'which referring to a whole clause':
Which can refer not only to a noun, but also to the whole of a previous clause. Note that what cannot be used in this way:
He got married again a year later, which surprised everybody (NOT...,
what surprised everybody).
A final point: we usually write on the blackboard, not to it.