如何从 Vim 运行 CoffeeScript?
我对 Vim 比较陌生(来自 TextMate),并且一直在使用 kchmck 的 Vim Coffeescript 插件。这很棒,但我怀念能够在 TextMate 中使用 cmd-R 使用 jashkenas 的 TextMate 包 运行 CoffeeScript 片段。有人对使用 Vim 设置这个有什么建议吗?
I'm relatively new to Vim (from TextMate), and have been using kchmck's Vim coffeescript plugin. It's great, but I miss being able to cmd-R in TextMate to run snippets of coffeescript using jashkenas's TextMate bundle. Anyone have any tips on setting this up with Vim?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您希望能够使用 Cmdr 在两者命令模式和编辑模式下运行,请将其添加到您的 ~/. vimrc:
inoremap
将在编辑模式下调用nnoremap
将在命令模式下调用If you'd like to be able to use Cmdr to run in both command mode and edit mode, add this to your ~/.vimrc:
inoremap
will be called in edit modennoremap
will be called in command mode对于现在关注此问题的任何人来说,
vim-coffee-script
现在支持CoffeeRun
命令。 (我认为最初提出这个问题时还没有。)CoffeeRun:运行一些 CoffeeScript
For anybody looking at this now,
vim-coffee-script
now supports theCoffeeRun
command. (I assume it didn't at the time this question was originally asked.)CoffeeRun: Run some CoffeeScript
该插件当前似乎没有提供此功能。也许您应该提交功能请求?
或者,您可以使用 Vim 插件进行编译,并使用 node-supervisor,每次 JS 发生变化时都会自动重新运行它。
It doesn't look like this is currently offered by the plugin. Perhaps you should file a feature request?
Alternatively, you could use the Vim plugin to do compilation and watch the compiled JS with something like node-supervisor, which would automatically re-run it every time the JS changes.
能够在 vim 中运行 CoffeeScript 非常方便。要进行设置,首先安装 kchmck 对 vim 的 CoffeeScript 支持(我使用 pathogen)。然后只需将以下内容放入您的 vimrc 文件中
,您应该能够输入
leader key + zz
来运行当前的 CoffeeScript 文件。请注意,这将在运行摩卡测试之前自动保存文件。Being able to run CoffeeScript inside vim is very convenient. To setup this up first install CoffeeScript support for vim from kchmck (I use pathogen for my installation). Then just place the following in your vimrc file
and you should be able to type your
leader key + zz
to run the current CoffeeScript file. Note that this will automatically save the file before running the mocha tests.我没有使用 CoffeeScript 的经验,但从你的第二个链接中我了解到你的文档被赋予了一个
coffee
命令。您尝试过
:!coffe %
吗?:!
运行外部命令,coffee
外部命令,%
代表当前文件。编辑
将此添加到您的
.vimrc
:nnoremap
映射仅在正常模式下工作,
是Cmdr 之后是命令序列,:!coffee %
命令,
输入I have no experience with CoffeeScript but from your second link I gather that your document is given to a
coffee
command.Did you try
:!coffe %
?:!
to run an external command,coffee
the external command,%
expanded by Vim at the time of execution, represents the current file.EDIT
Add this to your
.vimrc
:nnoremap
the mapping works in normal mode only,<D-r>
is Cmdr after that comes the sequence of commands,:!coffee %
the command,<CR>
Enter