diff --git a/lib/ex.coffee b/lib/ex.coffee index e259c90..684b2f6 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -199,9 +199,9 @@ class Ex substitute: (range, args) -> args = args.trimLeft() delim = args[0] - if /[a-z]/i.test(delim) + if /[a-z1-9\\"|]/i.test(delim) throw new CommandError( - "Regular expressions can't be delimited by letters") + "Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'") delimRE = new RegExp("[^\\\\]#{delim}") spl = [] args_ = args[1..] diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 803aa57..7bf10af 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -453,7 +453,14 @@ describe "the commands", -> keydown(':') submitNormalModeInputText(':substitute nanxngi') expect(atom.notifications.notifications[0].message).toEqual( - "Command error: Regular expressions can't be delimited by letters") + "Command error: Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'") + expect(editor.getText()).toEqual('abcaABC\ndefdDEF\nabcaABC') + + it "can't be delimited by numbers", -> + keydown(':') + submitNormalModeInputText(':substitute 1a1x1gi') + expect(atom.notifications.notifications[0].message).toEqual( + "Command error: Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'") expect(editor.getText()).toEqual('abcaABC\ndefdDEF\nabcaABC') describe "capturing groups", ->