Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add :delete command

  • Loading branch information...
commit b8ed5a012e1276063c8a9205dc5cf49949f43627 1 parent 3f3c32f
Guillermo López-Anglada guillermooo authored
Showing with 34 additions and 1 deletion.
  1. +15 −1 ex_command_parser.py
  2. +19 −0 ex_commands.py
16 ex_command_parser.py
View
@@ -164,6 +164,14 @@
ERR_UNWANTED_BANG,
ERR_UNWANTED_ARGS)
),
+ ('delete', 'd'): ex_cmd_data(
+ command='ex_delete',
+ args=['register', 'count'],
+ wants_plusplus=False,
+ wants_plus=False,
+ args_parser=None,
+ error_on=(ERR_UNWANTED_BANG,)
+ ),
}
@@ -306,8 +314,14 @@ def parse_command(cmd):
func = globals()[cmd_data.args_parser]
cmd_args = func(args)
else:
+ # xxx improve arg parsing: parsed differently based on generic arg
+ # name like "address", "file_name", "count", etc.
if cmd_data.args and args:
- cmd_args = dict(zip(cmd_data.args, [args]))
+ if len(cmd_data.args) > 1:
+ args = args.strip().split(' ', len(cmd_data.args))
+ else:
+ args = [args.strip()]
+ cmd_args = dict(zip(cmd_data.args, args))
parse_errors = []
if cmd_data.error_on:
19 ex_commands.py
View
@@ -401,3 +401,22 @@ def run(self, edit, range='.', pattern=''):
line_text = self.view.substr(self.view.line(r))
rv = re.sub(left, right, line_text, count=replace_count)
self.view.replace(edit, self.view.line(r), rv)
+
+
+class ExDelete(sublime_plugin.TextCommand):
+ def run(self, edit, range='.', register='', count=''):
+ # xxx somewhat different to vim's behavior
+ if register.isdigit():
+ count = register
+ register = ''
+
+ rs = get_region_by_range(self.view, range)
+ self.view.sel().clear()
+ for r in rs:
+ self.view.sel().add(r)
+
+ self.view.run_command('split_selection_into_lines')
+ self.view.run_command('run_macro_file',
+ {'file': 'Packages/Default/Delete Line.sublime-macro'})
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.