Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 11 commits
  • 4 files changed
  • 0 comments
  • 4 contributors
Feb 18, 2012
Erik Behrends Add text object motion 'vap' to visually select paragraph db15633
Erik Behrends Remove unused arguments 7e5376f
Feb 19, 2012
Erik Behrends Simplify 'vap' to call expand_selection_to_paragraph directly c8c69f2
Trent Ogren Don't force reindenting to indent past the first column
Based on this conversation:
sublimehq@ed9ccff#commitcomment-981083
a4692c4
Trent Ogren Correctly shrink selections when reversed
When shrinking selections to the first character, the cursor was being
left on the char *after* the selection if the selection was reversed.
This was causing issues when repeating linewise visual (un)indents,
since one line lower would be included in the indented region each time
it was repeated.

fixes #67
40215b5
Trent Ogren `cc` and `S` that take counts
fixes #66
448dd6e
Feb 20, 2012
Sublime HQ Pty Ltd Merge pull request #69 from misfo/dont-force-reindenting
Don't force reindenting to indent past the first column
d781c61
Mar 05, 2012
Sublime HQ Pty Ltd Merge pull request #70 from misfo/cc-and-S-with-count
`cc` and `S` that take counts
b1f9f44
Sublime HQ Pty Ltd Merge pull request #68 from misfo/shrink-selection-fix
Correctly shrink selections when reversed
f18cf24
Sublime HQ Pty Ltd Merge pull request #65 from behrends/vap
Add text object motion 'vap' to visually select paragraph
0b22b18
Mar 06, 2012
jskinner Renamed to align with build 2181 ea27061
18  Default.sublime-keymap
@@ -364,7 +364,7 @@
364 364
 		"context": [{"key": "setting.command_mode"}]
365 365
 	},
366 366
 
367  
-	{ "keys": ["="], "command": "set_action", "args": {"action": "reindent", "description": "Reindent"},
  367
+	{ "keys": ["="], "command": "set_action", "args": {"action": "reindent", "description": "Reindent", "action_args": {"force_indent": false}},
368 368
 		"context": [{"key": "setting.command_mode"}]
369 369
 	},
370 370
 
@@ -678,8 +678,9 @@
678 678
 	// Motions to allow double press to mean entire line
679 679
 
680 680
 	{ "keys": ["c"], "command": "set_motion", "args": {
681  
-		"motion": "vi_dont_move",
682  
-		"linewise": true},
  681
+		"motion": "vi_span_count_lines",
  682
+		"linewise": true,
  683
+		"motion_args": {"repeat": 1}},
683 684
 		"context":
684 685
 		[
685 686
 			{"key": "setting.command_mode"},
@@ -778,8 +779,9 @@
778 779
 	{ "keys": ["S"], "command": "set_action_motion", "args": {
779 780
 		"action": "enter_insert_mode",
780 781
 		"action_args": {"insert_command": "vi_delete"},
781  
-		"motion": "vi_dont_move",
782  
-		"motion_linewise": true},
  782
+		"motion": "vi_span_count_lines",
  783
+		"motion_linewise": true,
  784
+		"motion_args": {"repeat": 1}},
783 785
 		"context": [{"key": "setting.command_mode"}]
784 786
 	},
785 787
 
@@ -920,7 +922,11 @@
920 922
 		"motion_args": {"character": "{", "outer": true}},
921 923
 		"context": [{"key": "setting.command_mode"}, {"key": "vi_can_enter_text_object"}]
922 924
 	},
923  
-
  925
+	{ "keys": ["a", "p"], "command": "set_motion", "args": {
  926
+		"motion": "expand_selection_to_paragraph"},
  927
+		"context": [{"key": "setting.command_mode"}, {"key": "vi_can_enter_text_object"}]
  928
+	},
  929
+	
924 930
 	//
925 931
 	// Repeat digits
926 932
 	//
0  Base File (OSX).sublime-settings → Preferences (OSX).sublime-settings
File renamed without changes
18  vintage.py
@@ -482,6 +482,14 @@ def shrink_inclusive(r):
482 482
 def shrink_exclusive(r):
483 483
     return sublime.Region(r.b, r.b, r.xpos())
484 484
 
  485
+def shrink_to_first_char(r):
  486
+    if r.b < r.a:
  487
+        # If the Region is reversed, the first char is the character *before*
  488
+        # the first bound.
  489
+        return sublime.Region(r.a - 1)
  490
+    else:
  491
+        return sublime.Region(r.a)
  492
+
485 493
 # This is the core: it takes a motion command, action command, and repeat
486 494
 # counts, and runs them all.
487 495
 #
@@ -611,7 +619,7 @@ def run(self, edit, action_command, action_args,
611 619
                 # Apply the action to the selection
612 620
                 self.view.run_command(action_command, action_args)
613 621
                 if reindent and self.view.settings().get('auto_indent'):
614  
-                    self.view.run_command('reindent')
  622
+                    self.view.run_command('reindent', {'force_indent': False})
615 623
 
616 624
         if not visual_mode:
617 625
             # Shrink the selection down to a point
@@ -743,7 +751,7 @@ class ViCopy(sublime_plugin.TextCommand):
743 751
     def run(self, edit, register = '"'):
744 752
         set_register(self.view, register, forward=True)
745 753
         set_register(self.view, '0', forward=True)
746  
-        transform_selection_regions(self.view, lambda r: sublime.Region(r.a))
  754
+        transform_selection_regions(self.view, shrink_to_first_char)
747 755
 
748 756
 class ViPasteRight(sublime_plugin.TextCommand):
749 757
     # Ensure the register is picked up from g_input_state, and that it'll be
@@ -920,7 +928,7 @@ def run(self, edit, character):
920 928
             self.view.sel().add(s)
921 929
 
922 930
         if created_new_line and self.view.settings().get('auto_indent'):
923  
-            self.view.run_command('reindent')
  931
+            self.view.run_command('reindent', {'force_indent': False})
924 932
 
925 933
 class CenterOnCursor(sublime_plugin.TextCommand):
926 934
     def run(self, edit):
@@ -939,12 +947,12 @@ def run(self, edit):
939 947
 class ViIndent(sublime_plugin.TextCommand):
940 948
     def run(self, edit):
941 949
         self.view.run_command('indent')
942  
-        transform_selection_regions(self.view, lambda r: sublime.Region(r.a))
  950
+        transform_selection_regions(self.view, shrink_to_first_char)
943 951
 
944 952
 class ViUnindent(sublime_plugin.TextCommand):
945 953
     def run(self, edit):
946 954
         self.view.run_command('unindent')
947  
-        transform_selection_regions(self.view, lambda r: sublime.Region(r.a))
  955
+        transform_selection_regions(self.view, shrink_to_first_char)
948 956
 
949 957
 class ViSetBookmark(sublime_plugin.TextCommand):
950 958
     def run(self, edit, character):
9  vintage_motions.py
@@ -2,9 +2,12 @@
2 2
 from vintage import transform_selection
3 3
 from vintage import transform_selection_regions
4 4
 
5  
-class ViDontMove(sublime_plugin.TextCommand):
6  
-    def run(self, edit):
7  
-        pass
  5
+class ViSpanCountLines(sublime_plugin.TextCommand):
  6
+    def run(self, edit, repeat = 1):
  7
+        for i in xrange(repeat - 1):
  8
+            self.view.run_command('move', {'by': 'lines',
  9
+                                           'extend': True,
  10
+                                           'forward': True})
8 11
 
9 12
 class ViMoveByCharactersInLine(sublime_plugin.TextCommand):
10 13
     def run(self, edit, forward = True, extend = False, visual = False):

No commit comments for this range

Something went wrong with that request. Please try again.