How to reassign default editor for different file types from the command line?
There is a command line utility called Duti which can do this.

http://duti.sourceforge.net/

There is no easy way to do this using built-in commands.