jameyc / js-mask

More concise JavaScript using Vim's "conceal" feature

Home Page:http://www.vim.org/scripts/script.php?script_id=3324

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-mask: Because 'λ' is shorter than 'function'

A Vim plugin that makes your javascripts look more concise. The original intention is to make anonymous function less verbose and easier to understand at a glance. Requires Vim at least version 7.3.

The functionality can be described in this code below.

Before:

    function Add(b, c) { return b + c; };
    var log = function(txt) { console.log(txt) };
    setTimeout(function(){ console.log("wooot") }, 10);

After:

    λ Add(b, c) { return b + c };
    var log = λ(txt) { console.log(txt) };
    setTimeout(λ() { console.log("woooot") }, 10);

That's it.

Installation

Put the content of /after folder to ~/.vim folder.

What Does It Do?

It conceals the "function" keyword.

How Does It Work?

You still write the code in normal javascript. This plugin just makes it looks concise. It does not alter your code. The concealed parts will expand back to normal when you put the cursor at the containing line. Or when you open the code from another editor.

It Doesn't Do Much!

Yes. The main reason is when you move the cursor to a line, all concealed text on that line will expand. I find such behavior quite confusing because texts are moving around. If I had too much concealed keywords then there would be texts flying everywhere everytime I hit 'j' or 'k' and my head would explode.

Feel free to suggest additions and improvements via https://github.com/tyok/js-mask/issues. Or you can fork this from https://github.com/tyok/js-mask and add your own very personalized flavor.

Credits

This Vim plugin is inspired by https://github.com/ehamberg/vim-cute-python which, in turn, is inspired by http://www.vim.org/scripts/script.php?script_id=3200.

About

More concise JavaScript using Vim's "conceal" feature

http://www.vim.org/scripts/script.php?script_id=3324


Languages

Language:Vim Script 100.0%