2

From my command line I'm inputting the command

open .lists

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.

  • what about vim filename? – John C Jun 25 '14 at 14:02
5

The 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.

  • Worked perfectly. I added the alias to my .zshrc. – Ravenous Jun 25 '14 at 18:24
2

Try

mvim filename

You might have to set your PATH depending on how you installed it.

Take a look at https://stackoverflow.com/questions/2056137/how-to-run-mvim-macvim-from-terminal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.