Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to allow jumping behind a character if it's the last a line #52

Merged
merged 2 commits into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AceJump.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
// Toggles case sensitive search in word and character modes.
"search_case_sensitivity": true,

// If turned on, character mode will jump after a character
// it it's the last character on a line.
"jump_behind_last_characters": false,

// View settings that should be respected when switching the syntax
// highlighting mode. In case a plugin you use adds a new
// setting to a view, you probably want to add it to this list.
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ In case there are more places to jump to than labels available, labels will be b

## Customization

In order to access AceJump settings, go to ```Preferences > Package Settings > AceJump > Settings - User```.

### Key bindings

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

### Labels

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

### Highlighting

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```.
You can also set the syntsx scope that's used for highlighting by overriding ```labels_scope```. The default scope is ```invalid```.

### Case sensitivity

Ace jump is case sensitive by default. Case sensitivity can be toggled on and off by altering the ```search_case_sensitivity``` setting.

### Jumping behind the last character in a line

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.
18 changes: 16 additions & 2 deletions ace_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

next_search = False

# MODES
# 0: default (jumps in front of the selection)
# 1: select
# 2: add-cursor
# 3: jump-after
mode = 0

ace_jump_active = False
Expand Down Expand Up @@ -95,6 +100,7 @@ def run(self, current_buffer_only = False):
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
self.case_sensitivity = settings.get("search_case_sensitivity", True)
self.jump_behind_last = settings.get("jump_behind_last_characters", False)

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

def jump(self, index):
"""Performs the jump action"""

if self.target == "" or index < 0 or index >= last_index:
return

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

def jump(self, index):
global mode

view = self.changed_views[self.view_for_index(index)]
if self.jump_behind_last and "\n" in view.substr(hints[index].end()):
mode = 3

return AceJumpCommand.jump(self, index)

class AceJumpLineCommand(AceJumpCommand):
"""Specialized command for line-mode"""

Expand Down Expand Up @@ -310,7 +324,6 @@ def run(self):
global mode

mode = 0 if mode == 3 else 3
print(mode)

class AddAceJumpLabelsCommand(sublime_plugin.TextCommand):
"""Command for adding labels to the views"""
Expand Down Expand Up @@ -370,6 +383,7 @@ class PerformAceJumpCommand(sublime_plugin.TextCommand):
"""Command performing the jump"""

def run(self, edit, target):
global mode
if mode == 0 or mode == 3:
self.view.sel().clear()

Expand Down