Permalink
Browse files

Merge pull request #64 from misfo/paste-over-selection-fix

Paste over visual selections like Vim
  • Loading branch information...
2 parents ed9ccff + b679520 commit 75318ee18acd590c3f970a4d098f7c9e366eba69 @sublimehq sublimehq committed Feb 18, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 vintage.py
View
@@ -772,8 +772,11 @@ def advance(self, pt):
return pt + 1
def run(self, edit, register = '"'):
- transform_selection(self.view, lambda pt: self.advance(pt))
- self.view.run_command('paste_from_register', {'forward': True, 'register': register})
+ visual_mode = self.view.has_non_empty_selection_region()
+ if not visual_mode:
+ transform_selection(self.view, lambda pt: self.advance(pt))
+ self.view.run_command('paste_from_register', {'forward': not visual_mode,
+ 'register': register})
class ViPasteLeft(sublime_plugin.TextCommand):
# Ensure the register is picked up from g_input_state, and that it'll be
@@ -853,6 +856,9 @@ def run(self, edit, register, forward = True):
sublime.status_message("Undefined register" + register)
return
+ if self.view.has_non_empty_selection_region():
+ self.view.run_command('vi_delete')
+
regions = [r for r in self.view.sel()]
new_sel = []

0 comments on commit 75318ee

Please sign in to comment.