If I start the pi withe the display unplugged and then plug it in later, the screen resolution is too low. I can only solve this by restarting the machine. Is there a way to solve this without restarting the machine ?
As far as I'm aware, it's only by hardcoding a specific resolution into
hdmi_force_hotplug=1 hdmi_group=1 hdmi_mode=16
Should guarantee you HD resolution (1080p @60 Hz) if you plug in a cable after power up, and in my experience will work with most modern TVs and monitors. For a complete list of the possible options see here.
Set resolution into /boot/config.txt directory..
Force the monitor to HDMI mode so that sound will be sent over HDMI cable
Set monitor mode to DMT
Set monitor resolution to 1024x768 XGA 60Hz (HDMI_DMT_XGA_60)
Make display smaller to stop text spilling off the screen
overscan_left=20 overscan_right=12 overscan_top=10 overscan_bottom=10