How to programm for mega 8 by arduino uno r3

I have a Mega8 and I want to write the code by arduino software.
Could I use arduino for Mega8 and How can I program Mega8 by uno r3.
Very thanks.

Yes, you can write code for Atmega8 with IDE software.
Under Tools:Boards: select AtmegaNG or older with Atmega8.

Programming - you can try Arduino as ISP, I haven't tried it. Perhaps others with Atmega8 experience will help out.

It is the same like with e.g. ATmega328P. ATmega8 supports ISP, so you can use Arduino as ISP for program loading and IDE for code writing and compiling as CrossRoads mentioned. ATmega8 also supports bootloading and DIL package is same as for 328. It is possible to use it directly in the UNO with socket. It will be more comfortable if you want to develop the SW.