简体   繁体   English

Bash别名可从文件中编译coffeescript

[英]Bash alias to compile coffeescript from within file

Inside vim while writing a coffeescript file I use the following command to compile: 在vim内部,在编写coffeescript文件时,我使用以下命令进行编译:

  !coffeescript -c %

I tried creating a bash alias for this called cc . 我尝试为此创建一个bash别名cc Inside my root path I put the file named cc with the following contents !coffeescript -c % and then try to run it from within my coffeescript file but it does not work. 在我的根路径内,我将名为cc的文件包含以下内容!coffeescript -c % ,然后尝试从我的coffeescript文件中运行该文件,但它不起作用。

How can I create an alias that will compile coffeescript while I am inside Vim editing the file? 在Vim中编辑文件时,如何创建别名来编译coffeescript?

You probably want to create a vim mapping. 您可能要创建一个vim映射。 Something like this in your ~/.vimrc 〜/ .vimrc中类似这样的东西

nmap <Leader>cc :!coffeescript -c %<CR>

Then, in normal mode, you hit \\ c c 1 , the mapping invokes the command. 然后,在正常模式下,单击\\ c c 1 ,映射将调用命令。

1. backslash is the default "mapleader" character, you can define it to be something else. 1.反斜杠是默认的“ mapleader”字符,您可以将其定义为其他字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM