vi clone in JavaScript