diff --git a/README.md b/README.md index f042b98..92361d8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ 2. Added forward-backward search (bidirectional) search. You can jump forward or backward at the same time. `s`. One useful trick is to map `nmap s` and `vmap s` to use space bar instead and save one keystroke! 3. Added SelectLines function which allows you to select any range of lines using two consecutive easymotion calls. Default mappings are `cl, dl, vl, yl`. To yank a single line you can either type the same character(s) twice, or use '.' character. E.g. `vlb.` will select the line with character 'b'. Note: to promote good Vim habits, you should learn standard movement commands like `}}, vi(, va(, %, ][, ]], [(, etc.` before resorting to this function. 4. (Experimental) Added SelectPhrase function which allows you to make selection between any two characters. Default mapping are `cp, dp, vp, yp`. Example usage: type `vp` then press two input characters. Now the two input characters will be highlight on the same screen, and you can then type two combos to make selection. +5. Added matching target keys by smartcase option. +6. Added keep cursor column option when JK motion. ## Animated demonstration @@ -12,10 +14,16 @@ Two-key combo Select lines using `vl` + let g:EasyMotion_special_select_line = 1 " Default:0 + let g:EasyMotion_special_mapping_l = '{anykeys}' " Customize keymap + ![two-character key](http://homes.cs.washington.edu/~supasorn/easymotion2.gif) Yank lines using `yl`. You can copy lines without moving cursor back and forth between line you want to yank and line you want to paste. + let g:EasyMotion_special_select_phrase = 1 " Default:0 + let g:EasyMotion_special_mapping_p = '{anykeys}' " Customize keymap + ![two-character key](http://homes.cs.washington.edu/~supasorn/easymotion3.gif) This is an alpha version, which breaks multi-byte support, and others. @@ -71,3 +79,31 @@ about EasyMotion. ## Animated demonstration ![Animated demonstration](http://oi54.tinypic.com/2yysefm.jpg) + +## Vim-Lazymotion! + +Matching target keys by smartcase. You can type targets more lazily. + +Type `sv`, and all "v" and "V" characters are highlighted: + + V{a}im v{b}im V{c}IM. + +Press `b` to jump to the second "v": + + Vim vim VIM. + +Type `sV`, and all "V" characters are highlighted, not "v": + + V{a}im vim V{b}IM. + +Press `b` to jump to the second "V": + + Vim vim VIM. + + +Add following description in your vimrc: + + let g:EasyMotion_smartcase = 1 + +Default:0 + diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 995c936..85f3782 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -72,6 +72,7 @@ if g:EasyMotion_special_{fn.flag} silent exec 'onoremap ' . g:EasyMotion_special_mapping_{motion} . ' :call EasyMotion#' . fn.name . '()' silent exec 'nnoremap v' . g:EasyMotion_special_mapping_{motion} . ' :call EasyMotion#' . fn.name . '()' + silent exec 'nnoremap p' . g:EasyMotion_special_mapping_{motion} . ' :call EasyMotion#' . fn.name . 'Paste()' silent exec 'nnoremap y' . g:EasyMotion_special_mapping_{motion} . ' :call EasyMotion#' . fn.name . 'Yank()' endif endfor @@ -81,25 +82,7 @@ " }}} " Motion functions {{{ - function! EasyMotion#SelectLinesPaste() - let orig_pos = [line('.'), col('.')] - call EasyMotion#SelectLines() - normal y - keepjumps call cursor(orig_pos[0], orig_pos[1]) - if !g:EasyMotion_cancelled - normal p - endif - endfunction - - function! EasyMotion#SelectLinesYank() - let orig_pos = [line('.'), col('.')] - call EasyMotion#SelectLines() - normal y - keepjumps call cursor(orig_pos[0], orig_pos[1]) - "normal p - endfunction - - function! EasyMotion#SelectLines() + function! EasyMotion#SelectLines() "{{{ let orig_pos = [line('.'), col('.')] call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', 0, 0, 1) @@ -118,9 +101,25 @@ keepjumps call cursor(pos1[0], pos1[1]) endif endif - endfunction + endfunction "}}} + function! EasyMotion#SelectLinesYank() "{{{ + let orig_pos = [line('.'), col('.')] + call EasyMotion#SelectLines() + normal y + keepjumps call cursor(orig_pos[0], orig_pos[1]) + "normal p + endfunction "}}} + function! EasyMotion#SelectLinesPaste() "{{{ + let orig_pos = [line('.'), col('.')] + call EasyMotion#SelectLines() + normal y + keepjumps call cursor(orig_pos[0], orig_pos[1]) + if !g:EasyMotion_cancelled + normal p + endif + endfunction "}}} - function! EasyMotion#SelectPhrase() + function! EasyMotion#SelectPhrase() "{{{ let chars = s:GetSearchChar2(0) if empty(chars) return @@ -151,15 +150,23 @@ keepjumps call cursor(pos1[0], pos1[1]) endif endif - endfunction - - function! EasyMotion#SelectPhraseYank() + endfunction "}}} + function! EasyMotion#SelectPhraseYank() "{{{ let orig_pos = [line('.'), col('.')] call EasyMotion#SelectPhrase() normal y keepjumps call cursor(orig_pos[0], orig_pos[1]) - endfunction + endfunction "}}} + function! EasyMotion#SelectPhrasePaste() "{{{ + let orig_pos = [line('.'), col('.')] + call EasyMotion#SelectPhrase() + normal y + keepjumps call cursor(orig_pos[0], orig_pos[1]) + if !g:EasyMotion_cancelled + normal p + endif + endfunction "}}} function! EasyMotion#F(visualmode, direction) " {{{ diff --git a/doc/easymotion.txt b/doc/easymotion.txt index 673819e..7bd0f3e 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -1,4 +1,4 @@ -*easymotion.txt* Version 1.3. Last change: 2011 Nov 7 +*easymotion.txt* Version 1.3. Last change: 2013 Oct 5 ______ __ ___ __ _ @@ -23,13 +23,15 @@ CONTENTS *easymotion-contents* 4.3 EasyMotion_do_mapping .......... |EasyMotion_do_mapping| 4.4 EasyMotion_grouping ............ |EasyMotion_grouping| 4.5 EasyMotion_startofline ......... |EasyMotion_startofline| - 4.6 Custom highlighting ............ |easymotion-custom-hl| - 4.7 Custom mappings ................ |easymotion-custom-mappings| - 4.7.1 Leader key ............... |easymotion-leader-key| - 4.7.2 Custom keys .............. |easymotion-custom-keys| - 4.8 Easymotion other functions ..... |easymotion-other-mappings| - 4.8.1 Select Line .............. |easymotion-select-line| - 4.8.2 Select Phrase ............ |easymotion-select-phrase| + 4.6 EasyMotion_smartcase ........... |EasyMotion_smartcase| + 4.7 Custom highlighting ............ |easymotion-custom-hl| + 4.8 Custom mappings ................ |easymotion-custom-mappings| + 4.8.1 Leader key ............... |easymotion-leader-key| + 4.8.2 Custom keys .............. |easymotion-custom-keys| + 4.8.3 Special Custom keys ...... |easymotion-special-custom-keys| + 4.9 Easymotion special functions ... |easymotion-special-mappings| + 4.9.1 Select Line .............. |easymotion-select-line| + 4.9.2 Select Phrase ............ |easymotion-select-phrase| 5. License ............................ |easymotion-license| 6. Known bugs ......................... |easymotion-known-bugs| 7. Contributing ....................... |easymotion-contributing| @@ -83,26 +85,30 @@ And that's it! The default configuration defines the following mappings in normal, visual and operator-pending mode: - Mapping | Details - ------------------|---------------------------------------------- - f{char} | Find {char} to the right. See |f|. - F{char} | Find {char} to the left. See |F|. - t{char} | Till before the {char} to the right. See |t|. - T{char} | Till after the {char} to the left. See |T|. - w | Beginning of word forward. See |w|. - W | Beginning of WORD forward. See |W|. - b | Beginning of word backward. See |b|. - B | Beginning of WORD backward. See |B|. - e | End of word forward. See |e|. - E | End of WORD forward. See |E|. - ge | End of word backward. See |ge|. - gE | End of WORD backward. See |gE|. - j | Line downward. See |j|. - k | Line upward. See |k|. - n | Jump to latest "/" or "?" forward. See |n|. - N | Jump to latest "/" or "?" backward. See |N|. - s | Find(Search) {char} forward and backward. See |f| and |F|. - S | Beginning of word forward and backward. See |w| and |b|. + Mapping | Details + ---------------------|---------------------------------------------- + f{char} | Find {char} to the right. See |f|. + F{char} | Find {char} to the left. See |F|. + t{char} | Till before the {char} to the right. See |t|. + T{char} | Till after the {char} to the left. See |T|. + w | Beginning of word forward. See |w|. + W | Beginning of WORD forward. See |W|. + b | Beginning of word backward. See |b|. + B | Beginning of WORD backward. See |B|. + e | End of word forward. See |e|. + E | End of WORD forward. See |E|. + ge | End of word backward. See |ge|. + gE | End of WORD backward. See |gE|. + j | Line downward. See |j|. + k | Line upward. See |k|. + n | Jump to latest "/" or "?" forward. See |n|. + N | Jump to latest "/" or "?" backward. See |N|. + s | Find(Search) {char} forward and backward. See |f| and |F|. + S | Beginning of word forward and backward. See |w| and |b|. + | + | + {operator}l | Select, yank, paste, delete, or other operation of lines. See |easymotion-special-function|. + {operator}p | Select, yank, paste, delete, or other operation of phrase. See |easymotion-special-function|. See |easymotion-leader-key| and |mapleader| for details about the leader key. See |easymotion-custom-mappings| for customizing the default mappings. @@ -211,7 +217,16 @@ current column (by setting this option to 0) or to move along the first column Default: 1 ------------------------------------------------------------------------------ -4.6 Custom highlighting *easymotion-custom-hl* +4.6 Start of Line *EasyMotion_startofline* + +When using the |j| or |k| motion, the cursor can be configured to stay in the +current column (by setting this option to 0) or to move along the first column +(by setting this option to 1). + +Default: 1 + +------------------------------------------------------------------------------ +4.7 Custom highlighting *easymotion-custom-hl* The default EasyMotion configuration uses two highlighting groups that link to groups with default values. The highlighting groups are: @@ -262,14 +277,14 @@ There are two ways to override the default colors: hi link EasyMotionTarget2Second MatchParen < ------------------------------------------------------------------------------ -4.7 Custom mappings *easymotion-custom-mappings* +4.8 Custom mappings *easymotion-custom-mappings* EasyMotion allows you to customize all default mappings to avoid conflicts with existing mappings. It is possible to change the default leader key of all mappings to another key or sequence. It is also possible to fine tune the plugin to your need by changing every single sequence. -4.7.1 Leader key *EasyMotion_leader_key* *easymotion-leader-key* +4.8.1 Leader key *EasyMotion_leader_key* *easymotion-leader-key* The default leader key can be changed with the configuration option |EasyMotion_leader_key|. @@ -285,7 +300,7 @@ leader by setting this option in your vimrc: > < Default: '' -4.7.2 Custom Keys *easymotion-custom-keys* +4.8.2 Custom Keys *easymotion-custom-keys* All custom mappings follow the same variable format: > @@ -303,10 +318,28 @@ Note: The leader key defined by |EasyMotion_leader_key| is not prepended to your customized mappings! You have to provide full key sequences when setting these options. ------------------------------------------------------------------------------- -4.8 Easymotion other functions *easymotion-other-mappings* +4.8.3 Custom Keys for Special Function *easymotion-special-custom-keys* -4.8.1 Select Line *easymotion-select-line* +All special custom mappings follow the same variable format: > + + EasyMotion_special_mapping_{motion} = {mapping} +< +Example: > + + let g:EasyMotion_special_mapping_l = 'L' + let g:EasyMotion_special_mapping_p = 'p' +< +See |easymotion-default-mappings| for a table of motions that can be mapped +and their default values. + +Note: The leader key defined by |EasyMotion_leader_key| is not prepended to +your customized mappings! You have to provide full key sequences when setting +these options. + +------------------------------------------------------------------------------ +4.9 Easymotion special functions *easymotion-special-function* + +4.9.1 Select Line *easymotion-select-line* Default: Disabled @@ -330,7 +363,7 @@ Example: > Default: 0 -4.8.2 Select Phrase *easymotion-select-phrase* +4.9.2 Select Phrase *easymotion-select-phrase* (Experimental) SelectPhrase function which allows you to make selection between any two characters. @@ -385,5 +418,17 @@ can be downloaded here: http://www.vim.org/scripts/script.php?script_id=3437 +------------------------------------------------------------------------------ +Forked and modified by haya14busa + +Author: haya14busa +Source repository: https://github.com/haya14busa/vim-easymotion + +Ref: +- supasorn : two key combos and special function +- mtth : startofline(keep column) +- bootleq : fixed bufname bug + + ============================================================================== vim:tw=78:sw=4:ts=8:ft=help:norl: