vim-easymotion/README.md

230 lines
7.3 KiB
Markdown
Raw Normal View History

2014-02-02 19:58:47 -05:00
Vim motion on speed!
2014-01-30 07:32:28 -05:00
=====
2013-06-03 18:54:49 -04:00
2014-01-30 19:50:15 -05:00
![Animated demonstration](https://f.cloud.github.com/assets/3797062/2039359/a8e938d6-899f-11e3-8789-60025ea83656.gif)
2014-01-30 07:32:28 -05:00
About authors
=====
- Kim Silkebækken (https://github.com/Lokaltog)
- haya14busa (https://github.com/haya14busa) (from version 2.0)
2013-06-03 18:54:49 -04:00
2014-01-30 07:32:28 -05:00
Now, EasyMotion project revived!
======
[haya14busa](https://github.com/haya14busa) took over the project from
2014-01-30 19:50:15 -05:00
version 2.0. Improved default motions, implemented new useful features,
2014-01-30 07:32:28 -05:00
and fixed some bugs.
2013-06-03 18:54:49 -04:00
2014-01-30 07:32:28 -05:00
Now, EasyMotion is completely
2014-01-30 07:32:28 -05:00
- **Well-behaved**. It is consistent with the default motions of Vim and works well in all mode including dot repeat support.
- **Configurable**. You can easily configure its behavior and map any key you want.
- **Sophisticated**. It provide bi-directional motion, showing two label feature, smartcase & smartsign sensitive feature, repeat motion, and 'increment search' motion which can jump to even off-screen and so forth.
2013-06-03 18:54:49 -04:00
2014-01-30 07:32:28 -05:00
haya14busa implemented a lot of new feature and modify default behaviors, but I carefully considered backward compatibility, so you can easily update and enjoy significant benefit!
2011-03-28 06:54:03 -04:00
2014-01-30 07:32:28 -05:00
Introduction
=====
2011-06-01 04:14:20 -04:00
EasyMotion provides a much simpler way to use some motions in vim. It
takes the `<number>` out of `<number>w` or `<number>f{char}` by
highlighting all possible choices and allowing you to press one key to
2011-03-28 06:54:03 -04:00
jump directly to the target.
2011-06-01 04:14:20 -04:00
When one of the available motions is triggered, all visible text
preceding or following the cursor is faded, and motion targets are
2011-03-28 06:54:03 -04:00
highlighted.
2011-03-31 02:23:06 -04:00
EasyMotion is triggered by one of the provided mappings.
2011-03-28 06:54:03 -04:00
2014-01-30 07:32:28 -05:00
Important notes
=====
2011-04-07 04:29:03 -04:00
2014-01-30 19:50:15 -05:00
### About the default bindings
2013-10-04 07:35:22 -04:00
**The default leader has been changed to `<Leader><Leader>` to avoid
conflicts with other plugins you may have installed.** This can easily be
2011-11-07 08:39:51 -05:00
changed back to pre-1.3 behavior by rebinding the leader in your vimrc:
2011-04-07 04:29:03 -04:00
2014-01-30 07:32:28 -05:00
```vim
map <Leader> <Plug>(easymotion-prefix)
```
All motions are now triggered with `<Leader>` by default, e.g.
`<Leader>s`, `<Leader>gE`.
2011-04-07 04:29:03 -04:00
2014-01-30 19:50:15 -05:00
### About SelectLines & SelectPhrase for fork version user
These features are not **motion**, so I separated them as different plugins.
2011-04-07 04:29:03 -04:00
2014-01-30 19:50:15 -05:00
- https://github.com/haya14busa/vim-easyoperator-line
- https://github.com/haya14busa/vim-easyoperator-phrase
2011-03-28 06:54:03 -04:00
2014-01-30 07:32:28 -05:00
Usage example
=====
Type `<Leader><Leader>w`(`<Plug>(easymotion-w)`) to trigger the word motion `w`. When the motion is
2011-06-01 04:14:20 -04:00
triggered, the text is updated (no braces are actually added, the text
2011-03-31 02:23:06 -04:00
is highlighted in red by default):
2011-03-28 06:54:03 -04:00
<cursor>Lorem {a}psum {b}olor {c}it {d}met.
Press `c` to jump to the beginning of the word "sit":
Lorem ipsum dolor <cursor>sit amet.
2011-06-01 04:14:20 -04:00
Similarly, if you're looking for an "o", you can use the `f` motion.
2011-11-07 08:39:51 -05:00
Type `<Leader><Leader>fo`, and all "o" characters are highlighted:
2011-03-31 02:23:06 -04:00
<cursor>L{a}rem ipsum d{b}l{c}r sit amet.
Press `b` to jump to the second "o":
Lorem ipsum d<cursor>olor sit amet.
2011-06-01 04:14:20 -04:00
Jeffrey Way of Nettuts+ has also [written
a tutorial](http://net.tutsplus.com/tutorials/other/vim-essential-plugin-easymotion/)
2014-01-30 19:50:15 -05:00
about EasyMotion.
2011-03-28 06:54:03 -04:00
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
New feature from 2.0
-----
2013-12-21 09:58:24 -05:00
## Two key combo
1. Use one - two character key jump. Display two keys if one-character key is not enough, so you can see what two keys to type without waiting after pressing the first key.
2014-01-30 07:32:28 -05:00
## Support bidirectional motion
It provide forward-backward (bidirectional) search feature to all motion.
2014-02-01 01:00:26 -05:00
(e.g. `<Plug>(easymotion-s)`, `<Plug>(easymotion-bd-w)` and so forth)
2013-12-21 09:58:24 -05:00
2014-02-01 01:00:26 -05:00
You can jump forward or backward at the same time by `<Leader>s`.
One useful trick is to map `nmap s <Plug>(easymotion-s)` to use `s` instead and save one keystroke!
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
## 2 key find motion
2014-02-01 01:00:26 -05:00
EasyMotion provide 2-key find motions like vim-seek/vim-sneak. (e.g. `<Plug>(easymotion-s2)`)
2014-01-30 07:32:28 -05:00
![2-key-find-motion](https://f.cloud.github.com/assets/3797062/2039612/7cafcec8-89a5-11e3-8f2c-5f26a6b83efd.gif)
2014-01-30 19:50:15 -05:00
```vim
2014-02-01 01:00:26 -05:00
" Gif config
2014-01-30 19:50:15 -05:00
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
```
2014-01-30 07:32:28 -05:00
## 'n' key find motion
EasyMotion also provide 'n' key find motion like default 'search' motion of Vim.
2014-02-01 01:00:26 -05:00
- Incremental highlight
2014-01-30 07:32:28 -05:00
- Search off-screen by `<Tab>` & `<S-Tab>`
2014-02-01 01:00:26 -05:00
Scroll by `<Tab>` key (`<S-Tab>` is backward) and `<CR>` to execute.
2014-01-30 07:32:28 -05:00
![n-key-motion-scroll](https://f.cloud.github.com/assets/3797062/2039254/4fbf7276-899e-11e3-9bf3-1e446cabc097.gif)
2014-02-01 01:00:26 -05:00
Completely replace default search of Vim with EasyMotion example.
2014-01-30 07:32:28 -05:00
![replace-search](https://f.cloud.github.com/assets/3797062/2039751/64b72bd8-89a8-11e3-80ea-2a6b578040b2.gif)
2014-01-30 07:32:28 -05:00
```vim
2014-02-01 01:00:26 -05:00
" Gif config
2014-01-30 07:32:28 -05:00
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
```
2014-01-30 07:32:28 -05:00
## Within line motion
Every motion also support within line motion.(e.g. `<Plug>(easymotion-sl)`,
`<Plug>(easymotion-bd-wl)`, etc...)
2014-01-30 07:32:28 -05:00
These motion matches only current line.
2014-01-30 07:32:28 -05:00
Example: these motion extend `hjkl` motion!
```vim
2014-02-01 01:00:26 -05:00
" Gif config
2014-01-30 07:32:28 -05:00
map <Leader>h <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>l <Plug>(easymotion-linebackward)
2014-01-30 07:32:28 -05:00
let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
```
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
![hjkl-motoin](https://f.cloud.github.com/assets/3797062/2039413/d8b32ab2-89a0-11e3-894f-3e81db084cfd.gif)
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
## Find target by smartcase & smartsign!
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
Matching target keys by smartcase. You can type targets more easily.
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
In find motion(e.g. `<Plug>(easymotion-s)`), type 'v' and matches 'v' & 'V',
and 'V' matches only 'V'.
2013-12-21 09:58:24 -05:00
Add following description in your vimrc:
2014-01-30 07:32:28 -05:00
let g:EasyMotion_smartcase = 1
2013-12-21 09:58:24 -05:00
Default:0
2014-01-30 07:32:28 -05:00
Matching target keys by smartsign. You can type targets more easily.
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
In find motion, type '1' and matches '1' & '!', and '!' matches only '!'.
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
Add following description in your vimrc:
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
```vim
let g:EasyMotion_use_smartsign_us = 1 " US layout
" or
let g:EasyMotion_use_smartsign_jp = 1 " JP layout
```
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
## Migemo feature (for Japanese user)
2014-02-01 01:06:37 -05:00
Easymotion can match multibyte Japanese characters with a alphabet input.
For example, `<Leader><Leader>sa` can search 'あ'.
2014-01-30 07:32:28 -05:00
This feature doesn't require cmigemo because Easymotion includes regex
patterns generated by cmigemo. However if you installed `cmigemo`,
2-key and 'n' key find motion also support migemo feature.
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
Add following description in your vimrc:
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
```vim
let g:EasyMotion_use_migemo = 1
```
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
Default:0
2013-12-21 09:58:24 -05:00
2014-01-30 07:32:28 -05:00
## Repeat motion
2014-01-30 19:50:15 -05:00
**Repeat last motion:** `<Plug>(easymotion-repeat)`
**Repeat last find motion:**
In find motion(e.g. `<Plug>(easymotion-s)`), to type `<CR>` without
input characters invoke last find motion.
**Jump to next/previous match even off-screen:**
2014-01-30 07:32:28 -05:00
`<Plug>(easymotion-next)` & `<Plug>(easymotion-prev)`
2014-01-30 19:50:15 -05:00
**Dot repeat support:**
Require https://github.com/tpope/vim-repeat
You can use EasyMotion in operator-pending and press `.` to repeat!
It is well-behaved, consistent with default behavior of Vim.
2014-01-30 07:32:28 -05:00
![repeat-motion](https://f.cloud.github.com/assets/3797062/2039538/0aef66aa-89a4-11e3-8242-c27a5208cfca.gif)
```vim
2014-02-01 01:00:26 -05:00
" Gif config
2014-01-30 07:32:28 -05:00
" Require tpope/vim-repeat to enable dot repeat support
" Jump to anywhere with only `s{char}{target}`
" `s<CR>` repeat last find motion.
nmap s <Plug>(easymotion-s)
" Bidirectional & within line 't' motion
omap t <Plug>(easymotion-bd-tl)
" Use uppercase target labels and type as a lower case
let g:EasyMotion_use_upper = 1
" type `l` and match `l`&`L`
let g:EasyMotion_smartcase = 1
" Smartsign (type `3` and match `3`&`#`)
let g:EasyMotion_use_smartsign_us = 1
```
2014-01-30 19:50:15 -05:00
See `:help easymotion.txt` for more detail!
2014-01-30 07:32:28 -05:00
Pull requests are welcome including my English check! :)
2013-12-21 09:58:24 -05:00