Skip to content

Commit 415df6f

Browse files
authored
Merge pull request #52 from ice9js/feature/jump-after-last-character
Add a setting to allow jumping behind the last character in a line in character mode by default
2 parents bcb414f + db4c543 commit 415df6f

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

AceJump.sublime-settings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// Toggles case sensitive search in word and character modes.
99
"search_case_sensitivity": true,
1010

11+
// If turned on, character mode will jump after a character
12+
// it it's the last character on a line.
13+
"jump_behind_last_characters": false,
14+
1115
// View settings that should be respected when switching the syntax
1216
// highlighting mode. In case a plugin you use adds a new
1317
// setting to a view, you probably want to add it to this list.

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ In case there are more places to jump to than labels available, labels will be b
9898

9999
## Customization
100100

101+
In order to access AceJump settings, go to ```Preferences > Package Settings > AceJump > Settings - User```.
102+
101103
### Key bindings
102104

103105
Go to ```Preferences > Package Settings > AceJump > Key Bindings - User```.
@@ -113,9 +115,16 @@ The commands accept an optional Boolean `current_buffer_only` argument. When pre
113115

114116
### Labels
115117

116-
Go to ```Preferences > Package Settings > AceJump > Settings - User```,
117-
and override the key ```labels```.
118+
You can override the ```labels``` setting to provide your own set of labels to be used by AceJump.
118119

119120
### Highlighting
120121

121-
You can also set the syntsx scope that's used for highlighting by going to ```Preferences > Package Settings > AceJump > Settings - User```, and overriding ```labels_scope```.
122+
You can also set the syntsx scope that's used for highlighting by overriding ```labels_scope```. The default scope is ```invalid```.
123+
124+
### Case sensitivity
125+
126+
Ace jump is case sensitive by default. Case sensitivity can be toggled on and off by altering the ```search_case_sensitivity``` setting.
127+
128+
### Jumping behind the last character in a line
129+
130+
By setting ```jump_behind_last_characters``` to ```true```, AceJump will jump behind a character if it's the last character on a line, without the need to trigger jump after mode. This only works in character mode and is switched off by default.

ace_jump.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
next_search = False
99

10+
# MODES
11+
# 0: default (jumps in front of the selection)
12+
# 1: select
13+
# 2: add-cursor
14+
# 3: jump-after
1015
mode = 0
1116

1217
ace_jump_active = False
@@ -95,6 +100,7 @@ def run(self, current_buffer_only = False):
95100
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
96101
)
97102
self.case_sensitivity = settings.get("search_case_sensitivity", True)
103+
self.jump_behind_last = settings.get("jump_behind_last_characters", False)
98104

99105
self.view_settings = settings.get("view_settings", [])
100106
self.view_values = get_views_settings(
@@ -203,7 +209,6 @@ def remove_labels(self):
203209

204210
def jump(self, index):
205211
"""Performs the jump action"""
206-
207212
if self.target == "" or index < 0 or index >= last_index:
208213
return
209214

@@ -267,6 +272,15 @@ def after_jump(self, view):
267272
view.run_command("move", {"by": "characters", "forward": True})
268273
mode = 0
269274

275+
def jump(self, index):
276+
global mode
277+
278+
view = self.changed_views[self.view_for_index(index)]
279+
if self.jump_behind_last and "\n" in view.substr(hints[index].end()):
280+
mode = 3
281+
282+
return AceJumpCommand.jump(self, index)
283+
270284
class AceJumpLineCommand(AceJumpCommand):
271285
"""Specialized command for line-mode"""
272286

@@ -310,7 +324,6 @@ def run(self):
310324
global mode
311325

312326
mode = 0 if mode == 3 else 3
313-
print(mode)
314327

315328
class AddAceJumpLabelsCommand(sublime_plugin.TextCommand):
316329
"""Command for adding labels to the views"""
@@ -370,6 +383,7 @@ class PerformAceJumpCommand(sublime_plugin.TextCommand):
370383
"""Command performing the jump"""
371384

372385
def run(self, edit, target):
386+
global mode
373387
if mode == 0 or mode == 3:
374388
self.view.sel().clear()
375389

0 commit comments

Comments
 (0)