Created
January 4, 2012 07:38
-
-
Save matthijsgroen/1558986 to your computer and use it in GitHub Desktop.
Convert javascript to coffeescript (ideal for jasmine specs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" convert javascript to coffeescript | |
command! ConvertJs :call ConvertJs() | |
function! ConvertJs() | |
:norm =G | |
:silent :%s/;$//e | |
:silent :%s/var //ge | |
:silent :g/^\s\+})$/d | |
:silent :%s/function() {/->/ge | |
:silent :%s/^\(\s\+\)\(\w\+\)$/\1\2 = null/e | |
:silent :%s/function(\(\w\+\)) {/(\1) ->/ge | |
:silent :%s/\/\//#/ge | |
:silent :%s/beforeEach(->/beforeEach ->/e | |
:silent :g/^})$/d | |
:silent :%s/describe(/describe /ge | |
:silent :%s/it(/it /ge | |
:silent :%s/this\./@/ge | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment