If I sell a stock and the trade is done. Can I use the cash to buy a new stock/fund immediately?
Or I have to wait until tomorrow?
You have to wait for three (business) days. That's the time it takes for the settlement to complete and for the money to get to your account. If you don't wait - brokers will still allow you to buy a new stock, but may limit your ability to sell it until the previous sale is settled.
Here's a FAQ from Schwab on the issue.
It depends on the broker. The one I use (Fidelity) will allow me to buy then sell or sell then buy within 3 days even though the cash isn't settled from the first transaction. But they won't let me buy then sell then buy again with unsettled cash. Of course not waiting for cash to settle makes you vulnerable to a good faith violation.