From 7f667d90e0282a73b88f5f2738cf272071c1a0df Mon Sep 17 00:00:00 2001 From: Ian Germann Date: Sun, 22 Feb 2015 14:53:20 -0500 Subject: [PATCH] add split, vsplit, sp, and vsp commands --- lib/command.coffee | 5 +++-- lib/ex.coffee | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/command.coffee b/lib/command.coffee index 38d5765..393b295 100644 --- a/lib/command.coffee +++ b/lib/command.coffee @@ -11,10 +11,11 @@ class Command execute: (input) -> return unless input.characters.length > 0 + [command, args...] = input.characters.split(" ") - func = (new Ex)[input.characters] + func = (new Ex)[command] if func? - func() + func(args) else throw new CommandError("#{input.characters}") diff --git a/lib/ex.coffee b/lib/ex.coffee index 9e61de4..a6d8ce2 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -4,6 +4,31 @@ class Ex atom.workspace.getActiveEditor().save() else atom.workspace.getActivePane().saveActiveItemAs() + w: => @write() + split: (filePaths) -> + pane = atom.workspace.getActivePane() + if filePaths? and filePaths.length > 0 + newPane = pane.splitUp() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitUp(copyActiveItem: true) + + sp: (filePaths) => @split(filePaths) + + vsplit: (filePaths) -> + pane = atom.workspace.getActivePane() + if filePaths? and filePaths.length > 0 + newPane = pane.splitLeft() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitLeft(copyActiveItem: true) + + vsp: (filePaths) => @vsplit(filePaths) + module.exports = Ex