Wish and if only

I wish I knew the answer means that I do not know it now. English uses a past form after wish to create distance from the present reality. The tense looks past, but the meaning is present.
I wish this room were warmer. (It is cold now.)
If only we had more time. (We do not have enough now.)
If only is usually more emotional or emphatic than I wish. The grammar after both expressions is similar.
A present situation or a past regret?
Use a past simple form for a situation you want to be different now:
I wish I lived closer to work.
If only the bus came more often.
Use the past perfect for something earlier that you regret:
I wish I had saved a copy.
If only we had checked the date before booking.
Compare I wish I had more time (I lack time now) with I wish I had had more time yesterday (I did not have enough time then). The two forms of had in the second example are both needed: the first is the past perfect auxiliary; the second is the participle of have.
Choose the wish by choosing the problem
Different wishes describe different kinds of dissatisfaction. This table gives you a starting point:
| The reality | The wish | Why this form? |
|---|---|---|
| I live far from work. | I wish I lived closer. | A different present situation |
| I didn't apply in time. | I wish I had applied earlier. | A different past action |
| I can't swim well. | I wish I could swim better. | A different ability |
| He keeps interrupting. | I wish he wouldn't interrupt. | A desired change in behaviour |
Notice I wish I were taller. The verb refers to now, despite its past form. Were is a common hypothetical form with all subjects, especially in careful writing; was is also common with I/he/she in informal use.
When the problem is an ongoing activity, a past continuous form can describe the wished-for alternative: I wish I weren't working this weekend. The work is scheduled for the coming weekend, but you already see it as a fixed, unwanted situation. Compare I hope I don't have to work this weekend, which presents the outcome as still open.
Two hads can express two different jobs
I wish I had a car uses had as the past form of the main verb have. The wish concerns owning a car now.
I wish I had had a car on that trip uses had had: auxiliary had plus participle had. The wish concerns possession on a completed trip. Try replacing have a car with take a map: I wish I had taken a map has the same past-perfect structure. The repeated word is grammatical, not a typing error.
Would and could express different wishes
Use wish + would when you want someone’s behaviour or a situation to change, often because it is annoying or outside your control:
I wish the neighbours would turn the music down.
If only the printer would work properly.
For an ability or possibility you lack, use could:
I wish I could stay for dinner. (I cannot.)
If only we could travel more often.
Do not use would as a universal replacement for a past form. I wish I knew her number means I do not know it; I wish she would give me her number expresses a desire for her to do something. For your own difficulty, I wish I could stop worrying is the natural choice when describing inability; I wish I didn't worry so much describes an unwanted habit.
Wish can have a different meaning
Not every wish introduces an unreal situation. In I wish you a safe journey, it means “hope for” and takes an object plus a noun phrase. This is different from I wish I were travelling with you, where the speaker imagines a different reality.
Hope usually looks towards a possible future or a desired fact: I hope the train is on time. Wish with an unreal past form signals that the speaker sees a gap between reality and desire: I wish the train were on time implies that it probably is not.
When the regret concerns a result that might have been different, a third conditional is also possible: If we had left earlier, we would have caught the train. I wish we had left earlier focuses directly on regret; the conditional spells out the imagined consequence.
From a complaint to the right sentence
Consider a student preparing for an exam:
I wish I understood conditionals better.
I wish I had revised them last week.
I wish my flatmates would turn the television down.
I wish I could concentrate.
The first describes current knowledge, the second regrets a missed past action, the third asks for a change in other people's behaviour, and the fourth concerns ability. One situation can contain several different wishes.
Avoid making would the default form for your own situation: I wish I would know the answer should be I wish I knew the answer. For a personal habit, I wish I could stop checking my phone or I wish I didn't check my phone so often is usually a clearer choice.
If only can stand as an emotional statement on its own: If only I'd listened! It does not need a result clause. If you want to explain the consequence too, a conditional may help: If I'd listened, I wouldn't have made that mistake.
For a future wish you regard as possible, prefer hope: I hope you pass. I wish you success is also natural, but it uses wish + person + noun, a different construction. Keeping these meanings separate prevents I wish you will pass.
Sources and further reading
Try this structure in a short practice set with instant feedback.
Start practice