lazy-motion

Rapid cursor positioning with fuzzy search

jrajav

953

5

0.7.0

MIT

GitHub

lazy-motion

Rapid cursor positioning with fuzzy, lazy search.

gif

Feature

How it works.

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.

  1. Invoke lazy-motion:forward from keymap.
  2. Input c?d to input panel.
  3. core:confirm to land or core:cancel to cancel.

Other examples

Like the example above you can reach target position with very lazy and fuzzy key type.

Why label jump approach not worked for me.

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.

Commands

atom-text-editor

atom-text-editor.lazy-motion

NOTE: Search always wrap from end-to-top or top-to-end.

Configuration

Keymap

No keymap by default.
You need to set your own keymap in keymap.cson.

Normal user

'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'

Emacs user

'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'

My setting

'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'

Change Style

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;
    }
  }
}

Language specific wordRegExp configuration.

You can specify wordRegExp configuration per language.

See Scoped Settings, Scopes and Scope Descriptors and API/Config for details.

"*": # This is global scope. Used as default.
  # <snip>
  "lazy-motion":
    wordRegExp: 'xxxx'
  # <snip>
".go.source": # This is Go specific,
  "lazy-motion":
    wordRegExp: 'xxxx'

Credits