From 4ec1c56077803bb047512fca1d6d9a19dddd145f Mon Sep 17 00:00:00 2001 From: Caio Cutrim Date: Thu, 26 Nov 2015 12:20:32 -0300 Subject: [PATCH] I added :wa, :qa, :waq shortcuts commands --- lib/ex.coffee | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index 684b2f6..e83e7f4 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -71,10 +71,17 @@ class Ex @registerCommand: (name, func) => @singleton()[name] = func + # quit function is used on :q command quit: -> atom.workspace.getActivePane().destroyActiveItem() - + # quit function is used on :qa command shortcut + quitAll: -> + atom.workspace.getPanes()[0].destroy() + # both functions is referenced over here + # when this commands has trigered q: => @quit() + # ...and here + qa: => @quitAll() tabedit: (range, args) => if args.trim() isnt '' @@ -169,17 +176,28 @@ class Ex trySave(-> saveAs(fullPath)).then(deferred.resolve) deferred.promise + # save all files function + saveAll: -> + atom.workspace.saveAll() + # save all then quit + saveAllThenQuit: - > + atom.workspace.saveAll() + @quitAll() w: (args...) => @write(args...) wq: (args...) => @write(args...).then => @quit() + # save all files :wa command + wa: => + @saveAll() + # save all, then quit shortcut + waq: => + @saveAllThenQuit() xit: (args...) => @wq(args...) - wa: -> - atom.workspace.saveAll() split: (range, args) -> args = args.trim() @@ -199,9 +217,9 @@ class Ex substitute: (range, args) -> args = args.trimLeft() delim = args[0] - if /[a-z1-9\\"|]/i.test(delim) + if /[a-z]/i.test(delim) throw new CommandError( - "Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'") + "Regular expressions can't be delimited by letters") delimRE = new RegExp("[^\\\\]#{delim}") spl = [] args_ = args[1..]