I am an undergraduate level student planning to put out a research paper for publication. The second author is a PhD student who has helped me to do much editing (including re-writing my entire paper into a concise and expressive form, and also the numerical simulation part). I think he helps me a lot. My friend suggests to me to buy him a gift card at the end to express my gratitude. I am wondering would this be a good idea or not?
Others may differ in opinion, but I personally think that gift cards are a poor choice for expressing personal gratitude. The problem is that gift cards are effectively cash with spending restrictions. Your colleague has invested time and energy in helping you, and giving cash would essentially be saying how much per hour you feel their time is worth.
Instead, I would recommend offering something like taking them out for a fancy lunch, which invests your time and gives the two of you a chance to do some informal bonding and building of your professional relationship. Unless, of course you don't actually want to spend time alone with this colleague (many possible good reasons for that), in which case I would still recommend looking for some way to express gratitude that shows an investment of time and caring beyond just money.
I would probably kindly reject such a gift, since it is essentially giving money and I do not want to receive money for this type of thing. I would be fine with a bottle of wine or a similar thing. It is not money and the "price" part of it is not that important (I, after all, don't even know the price).
Another choice is to invite the person for whatever you think (or know) they like: sushi, good burger, NHL match, ... Just don't "overshoot it", you're younger and they need not be exactly interested in coming for an NHL match with you, because they may plan to go there with someone else or whatever. Use some sort of common sense for this.
Last but not least (and I consider that the best option), invite them for a beer. In my country (Czechia), you even say "Thanks, I owe you a beer" when someone does something good for you (mostly like in your case: spending their time on your project with no reward expected), and quite often the people really end up having a beer or two. I think you can invite them for a beer in most countries in the world.
If I was the person who helped, I would indeed be very positively surprised to receive anything at all from you (unless it's something offensive). You don't have an obligation to do it and so most people would appreciate whatever time or money you spend into expressing your gratitude.
That said, for the choice I would try to avoid "objects" which are usually rather useless and tend to end up gathering dust somewhere. Food and/or drink are good choices in my opinion. My mother in law knows I like beer and I love it when she gets me four or five different styles when she makes me a present.
Another important issue is: do not overdo it. A present of value, say, 50 or 100$, can not only make the recipient uncomfortable, but it might also be against the regulations of the university. There are often anti-corruption regulations that prohibit university employees from receiving gifts, excluding very small token ones.