I've been playing with hostfiles on my MacBook Pro this morning.
He's how I did it...
1. Search for Terminal in Spotlight;
2. Run >cd /etc
3. >sudo vi hosts
4. To enter edit mode, hit "esc" then i.
5. Do what you need to do;
6. Hit "esc"
7. Hit : , w , q . This saves and closes the file.
8. Quit Terminal