Last Updated: February 25, 2016
·
749
· lukaszkorecki

JλvλScript

I like JavaScript. No really. I like it.

The only thing that bugs me is writing function all the time. And seeing function everywhere. For such a fundamental part of the language, the keyword is way too long.

Lets fix it.

Picture

" replace 'function' with λ
au BufNewFile,BufRead *.js syntax keyword javasScriptFunction function conceal cchar=λ
au BufNewFile,BufRead *.js hi! link javasScriptFunction Conceal
au BufNewFile,BufRead *.js setlocal conceallevel=2
" add abbreviations for JS
" f_
"  expands to
" function() {
" <cursor>
"
" }
" f- expands to
" function() { <cursor )
autocmd Filetype javascript iabbr f_ function(){<CR>:}<ESC>?:<CR><ESC>xO
autocmd Filetype javascript iabbr f- function(){:}<ESC>?:<CR><ESC>xO

Code is also available as a gist https://gist.github.com/3305649