Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Paste over visual selections like Vim
  • Loading branch information...
commit 75318ee18acd590c3f970a4d098f7c9e366eba69 2 parents ed9ccff + b679520
Sublime HQ Pty Ltd authored February 18, 2012

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. 10  vintage.py
10  vintage.py
@@ -772,8 +772,11 @@ def advance(self, pt):
772 772
             return pt + 1
773 773
 
774 774
     def run(self, edit, register = '"'):
775  
-        transform_selection(self.view, lambda pt: self.advance(pt))
776  
-        self.view.run_command('paste_from_register', {'forward': True, 'register': register})
  775
+        visual_mode = self.view.has_non_empty_selection_region()
  776
+        if not visual_mode:
  777
+            transform_selection(self.view, lambda pt: self.advance(pt))
  778
+        self.view.run_command('paste_from_register', {'forward': not visual_mode,
  779
+                                                      'register': register})
777 780
 
778 781
 class ViPasteLeft(sublime_plugin.TextCommand):
779 782
     # 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):
853 856
             sublime.status_message("Undefined register" + register)
854 857
             return
855 858
 
  859
+        if self.view.has_non_empty_selection_region():
  860
+            self.view.run_command('vi_delete')
  861
+
856 862
         regions = [r for r in self.view.sel()]
857 863
         new_sel = []
858 864
 

0 notes on commit 75318ee

Please sign in to comment.
Something went wrong with that request. Please try again.