从命令行使用 MacVim 打开文件

Rav*_*ous 3 command-line macvim macos

从我的命令行我输入命令

open .lists
Run Code Online (Sandbox Code Playgroud)

这是在 TextEdit 中打开文本文件。我很确定一些文件扩展名会用 MacVim 打开。我不确定如何使用 MacVim 打开所有文本文件。

Ber*_*ert 8

open命令将使用默认程序打开文件,就像您在 Finder 中双击文件一样。但是,该命令有几个选项:

 -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
Run Code Online (Sandbox Code Playgroud)

这为您提供了几种可能性:

您可以通过“信息对话框”将文件扩展名与应用程序(例如 MacVim)相关联。只需选择文件并点击 Cmd-i,然后转到“打开方式”选项卡,选择应用程序并点击“全部更改...”。这将更改该文件的默认应用程序,该open命令将按您的意愿工作。

另一种选择是为~/.profile使用 MacVim 打开文件的别名添加别名。就像是:

alias edit="open -a MacVim.app $1"
Run Code Online (Sandbox Code Playgroud)

然后你可以输入edit filename终端,文件将在 MacVim 中打开。


归档时间:

查看次数:

10137 次

最近记录:

11 年,7 月 前