moll/vim-node — pull request #4 by nylen (2013-09-24 18:52:58+00:00)
Title: Add require() helper

### Node.js `require()` helper

This code maps the commands `:Require` and `:Unrequire` to help with managing `require()` statements in Node.js code. Commands `:R` and `:UR` are also created if they don't already exist.

### A brief usage example, starting in a blank node.js file:

Run these vim commands:

:Require async
:Require cp=child_process
:Require ./lib/somelib
:Require mongodb.MongoClient
:Unrequire mongodb
:Require mc=mongodb.MongoClient

The file will go through these changes:

var async = require('async');

var async = require('async'),
cp = require('child_process');

var async = require('async'),
cp = require('child_process'),
somelib = require('./lib/somelib');

var async = require('async'),
cp = require('child_process'),
MongoClient = require('mongodb'),
somelib = require('./lib/somelib');

var async = require('async'),
cp = require('child_process'),
somelib = require('./lib/somelib');

var async = require('async'),
cp = require('child_process'),
mc = require('mongodb').MongoClient,
somelib = require('./lib/somelib');

### Improvements

This has been very useful to me so far, but it's my first piece of serious vimscript, so changes and improvements welcome!