I have trouble using prefer + to infinitive or + V.ing.
Could anyone tell me the differences between them?
There is no siginificant difference in meaning between I prefer doing and I prefer to do. If we prefer one thing to another, then we use the gerund:
I prefer walking to riding.