From my command line I'm inputting the command
This is opening the text file in TextEdit. I'm pretty sure some file extensions will open with MacVim. I'm unsure how to get all text files to open with MacVim.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
open command will open the file with the default program, just as if you had double-clicked the file in Finder. However, the command has a few options:
-a application Specifies the application to use for opening the file -e Causes the file to be opened with /Applications/TextEdit -t Causes the file to be opened with the default text editor, as determined via LaunchServices
This allows you a few possibilities:
You can associate a file extension with an app (such as MacVim) via the "Info dialog". Just select the file and hit Cmd-i, then go to the "Open with" tab, select app and hit "Change all...". This will change the default application for that file and the
open command will work as you wish.
Another option is to add an alias to your
~/.profilethat uses MacVim to open files. Something like:
alias edit="open -a MacVim.app $1"
Then you can type
edit filename in Terminal and the file will open in MacVim.
You might have to set your PATH depending on how you installed it.