Last Updated: February 25, 2016
·
929
· 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

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside