I found another solution as above solution didn't work for me (I don't know why).
Create a file mvim
in /usr/bin/
by:
sudo vim /usr/bin/mvim
And paste the following two lines:
#!/bin/bash
/usr/bin/gnome-terminal -e "/usr/bin/vim $1"
Press :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:
mvim anyfile
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. /usr/bin/mvim
.
And yay! meanwhile you created your own command!