I found another solution as above solution didn't work for me (I don't know why).
Create a file
sudo vim /usr/bin/mvim
And paste the following two lines:
/usr/bin/gnome-terminal -e "/usr/bin/vim $1"
:wq and Enter to save.
Now give executable permissions to this your command by:
sudo chmod +x /usr/bin/mvim
To test if it's gonna work or not, you can type:
It should open a new terminal with
anyfile opened in vim.
Now open your
file manager (mine is SpaceFM) and
right click a text file and click
Properties. If there is an option of open with command then type in the path to your command i.e.
And yay! meanwhile you created your own command!