Most of the time one or the other feels better, but every so often, "which" vs. "what" trips me up.
So, what's the exact difference and when should you use one or the other?
"Which" is more formal when asking a question that requires a choice between a number of items. You can use "What" if you want, though.
Generally speaking, you can replace the usage of "which" with "what" and be OK grammatically. It doesn't always work the other way around, however. There needs to be a context of choice. For example:
Which/What flavor of ice cream do you want?
- Either is fine, but "which" is better.
Which/What do you want for dessert?
- "Which" only works in the context of being presented with choices (e.g. a dessert cart right in front of you).
Questions of attribute which and what: We usually use which when we are asking about a fixed or limited number of things or people, and what when we are not. Often, however, we can use either which or what with little difference in meaning. Compare:
What towns do we go through on the way?
The speaker doesn't know the area.
Which towns do we go through on the way?
The speaker knows the area and the towns in it.
If you mean when they are conjunctions, it is another question.