Move main code inside Editor class

Before open a new file now we cleanup the Editor, so the new file get the cursor
on the first character.