Is it grammatically correct to use one-word sentence "Why?" as "Why do you ask?", for example in such context:
– Did you visit that shop yesterday? – Yes. Why?
It's informal and colloquial. Use it when you're talking. Use it when you're writing dialog. Don't use it in formal writing.
Of course, we know that the shorthand expression "why?" is not a sentence on its own because it's missing the verb. So it should not be used in formal writing.
However, I found it interesting to examine what happens when it is used in a conversation—other than with a cheeky reply like "why what?" :-)
Here are my thoughts:
The exact intent of the one using the ambiguous expression 'Why?' may only be deduced by a larger context. However, the speaker almost invariably intends the predicate of one's expression to either be "the question" asked or "the reply" expected. The speaker would most like avoid this expression when the meaning is more complex.
For example, consider the following dialogue snippet:
This seems to be sufficient to mean one of two things within the limited scope of the dialogue:
In the first case, Jane's expression makes "the answer" direct object predicate, in the second it makes "the question" direct object predicate; the subjects, being "I" and "you" respectively.
However if we consider the following permutation:
where you is the subject, me is the in-direct predicate, and the implied expression, the question is the "prepositional object predicate", the sentence is complex and the shorthand "why?" would seem to cause a higher degree of ambiguity. Here, and in similar or more complex expressions, I believe that the speaker would be compelled to clarify by using the explicit sentence rather than an implicit "Why?" as a shorthand expression.
Well that was my thought on it :-) not sure if it helps.