Rapid cursor positioning with fuzzy, lazy search.
- Search word within buffer with fuzzy search by fuzzaldrin.
- Display
current / total
match count in input panel and hover indicator. - Incrementally scroll(visit) to matched position.
- Don't change cursor position unless you confirm(important for cursor-history like pakcage).
- Differentiate color for top(blue) and bottom(red) entry of matches.
- Highlight original cursor position while searching and flash current matching.
- Flash screen if no match.
- Support search history, and set cursor word as search text.
Lets say you are editing over 200 lines of CoffeeScript file.
And you want to go to line where code @container?.destroy()
is to change it.
With lazy-motion, you can reach target in following way.
- Invoke
lazy-motion:forward
from keymap. - Input
c?d
to input panel. core:confirm
to land orcore:cancel
to cancel.
ca)
to reach line containingcancel()
.gemade
to reach line containing@flashingDecoration?.getMarker().destroy()
.
Like the example above you can reach target position with very lazy and fuzzy key type.
Until now I released vim-smalls and its Atom port.
And also hacked jumpy and vim-easymotion as exercise to create smalls.
But as for me this label jump system not work, I couldn't adapt to it.
The reason is simple.
The label jump constrains me to enter label precisely which result in my concentration (or zone or flow) lost.
Of course this label jump packages let me reach target position with minimum key typing.
But in my opinion, it's only good for demonstration.
In real world coding, the brain context switch the label jump enforces is too expensive to use on a daily basis.
lazy-motion:forward
: Search forward.lazy-motion:backward
: Search backward.lazy-motion:forward-again
: Search last word again.lazy-motion:backward-again
: Search last word again.lazy-motion:forward-cursor-word
: Search with cursor word.lazy-motion:backward-cursor-word
: Search with cursor word.
core:confirm
: Confirm.core:cancel
: Cancel.core:move-up
: Set previous history as search word.core:move-down
: Set next history as search word.lazy-motion:set-history-next
: Set next history as search word.lazy-motion:set-history-prev
: Set previous history as search word.lazy-motion:set-cursor-word
: Set cursor word as search word.
NOTE: Search always wrap from end-to-top or top-to-end.
wordRegExp
: Used to build candidate word list. See this for detail.showHoverIndicator
: Show hover indicator while searching.historySize
: Max length of history.saveHistoryOnCancel
: If false, canceled search won't saved to history.
No keymap by default.
You need to set your own keymap in keymap.cson
.
'atom-text-editor':
'ctrl-s': 'lazy-motion:forward'
'ctrl-cmd-r': 'lazy-motion:backward'
'atom-text-editor.lazy-motion':
']': 'lazy-motion:forward'
'[': 'lazy-motion:backward'
'atom-text-editor':
'ctrl-s': 'lazy-motion:forward'
'ctrl-r': 'lazy-motion:backward'
'.platform-darwin atom-text-editor.lazy-motion':
'ctrl-s': 'lazy-motion:forward'
'ctrl-r': 'lazy-motion:backward'
'ctrl-g': 'core:cancel'
'atom-text-editor.vim-mode-plus.normal-mode, atom-text-editor.vim-mode-plus.visual-mode':
's': 'lazy-motion:forward'
'ctrl-p': 'lazy-motion:forward-again'
'atom-text-editor.lazy-motion':
';': 'core:confirm'
']': 'lazy-motion:forward'
'[': 'lazy-motion:backward'
'cmd-e': 'lazy-motion:set-cursor-word'
Style used in lazy-motion is defined in main.less.
You can change style bye overwriting these style in your style.css
.
e.g.
atom-text-editor::shadow {
// Change border
.lazy-motion-match.current .region {
border-width: 2px;
}
// Change hover label
.lazy-motion-hover {
color: @text-color-selected;
background-color: @syntax-selection-color;
&.first {
background-color: @syntax-color-renamed;
}
&.last {
background-color: @syntax-color-removed;
}
}
}
You can specify wordRegExp
configuration per language.
See Scoped Settings, Scopes and Scope Descriptors and API/Config for details.
- in your
config.cson
.
"*": # This is global scope. Used as default.
# <snip>
"lazy-motion":
wordRegExp: 'xxxx'
# <snip>
".go.source": # This is Go specific,
"lazy-motion":
wordRegExp: 'xxxx'
- This package was originally created by @t9md.