简体   繁体   中英

Bash alias to compile coffeescript from within file

Inside vim while writing a coffeescript file I use the following command to compile:

  !coffeescript -c %

I tried creating a bash alias for this called 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.

How can I create an alias that will compile coffeescript while I am inside Vim editing the file?

You probably want to create a vim mapping. Something like this in your ~/.vimrc

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

Then, in normal mode, you hit \\ c c 1 , the mapping invokes the command.

1. backslash is the default "mapleader" character, you can define it to be something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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