First of all you should notice that there are two types of text editors..
The command line editors such as vim, nano, emacs, etc..
GUI text editors such as gedit, kate, ...
The default text editor when using the GUI is not the same as the command line text editors so when you are opening a file using GUI you probably are using the GUI text editors which is gedit by default. While when using the command line so you are using the command line text editors.
To know that is the default command line text editor in your system you can try one of the following methods:
sudo update-alternatives --config editor
This command show you the text editors. The one you are using has the * in front