Question; External power and USB

Hello, I would like to know if I can connect my Arduino UNO by USB, to write the code while at the same time I feed my components by external power.

Please explain a bit more what’s happening.

I do that all the time. Be sure all the grounds are connected. DO NOT DO THAT if your project is controlling mains power unless you have experience or somebody mentoring you that does and can be with you when you power it up.