From 3f423c28c94379d58d945ce2de2e80851c00323c Mon Sep 17 00:00:00 2001 From: haya14busa Date: Tue, 18 Feb 2014 13:54:44 +0900 Subject: [PATCH] Improve iskeyword word motions - Make within line word motion compatible with iskeyword by default - Add test - Update doc - Thanks @yuex: #101 --- autoload/EasyMotion.vim | 6 ++--- doc/easymotion.txt | 54 +++++++++++++++++++++++++++++++---------- t/easymotion_spec.vim | 26 +++++++++++++++++++- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index c590d58..1c5a898 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -3,7 +3,7 @@ " Author: Kim Silkebækken " haya14busa " Source: https://github.com/Lokaltog/vim-easymotion -" Last Change: 16 Feb 2014. +" Last Change: 18 Feb 2014. "============================================================================= " Saving 'cpoptions' {{{ scriptencoding utf-8 @@ -232,12 +232,12 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{ endfunction " }}} function! EasyMotion#WBL(visualmode, direction) " {{{ let s:flag.within_line = 1 - call EasyMotion#WB(a:visualmode, a:direction) + call EasyMotion#WBK(a:visualmode, a:direction) return s:EasyMotion_is_cancelled endfunction " }}} function! EasyMotion#EL(visualmode, direction) " {{{ let s:flag.within_line = 1 - call EasyMotion#E(a:visualmode, a:direction) + call EasyMotion#EK(a:visualmode, a:direction) return s:EasyMotion_is_cancelled endfunction " }}} function! EasyMotion#LineAnywhere(visualmode, direction) " {{{ diff --git a/doc/easymotion.txt b/doc/easymotion.txt index b9d1b84..f5160ac 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -1,4 +1,4 @@ -*easymotion.txt* Version 2.0 Last change:14 Feb 2014. +*easymotion.txt* Version 2.0 Last change:18 Feb 2014. ______ __ ___ __ _ @@ -152,7 +152,15 @@ EasyMotion table *easymotion-plug-table* (easymotion-next) | See |(easymotion-next)| (easymotion-previous) | See |(easymotion-previous)| (easymotion-sol-j) | See |(easymotion-sol-j)| + (easymotion-sol-k) | See |(easymotion-sol-k)| (easymotion-eol-j) | See |(easymotion-eol-j)| + (easymotion-eol-k) | See |(easymotion-eol-k)| + (easymotion-iskeyword-w) | See |(easymotion-iskeyword-w)| + (easymotion-iskeyword-b) | See |(easymotion-iskeyword-b)| + (easymotion-iskeyword-bd-w) | See |(easymotion-iskeyword-bd-w)| + (easymotion-iskeyword-e) | See |(easymotion-iskeyword-e)| + (easymotion-iskeyword-ge) | See |(easymotion-iskeyword-ge)| + (easymotion-iskeyword-bd-e) | See |(easymotion-iskeyword-bd-e)| | Within Line Motion | See |easymotion-within-line| ----------------------------------|--------------------------------- @@ -360,6 +368,26 @@ End of Line JK motion *(easymotion-eol-j)* *(easymotion-eol-k) > map J (easymotion-eol-j) map K (easymotion-eol-K) +< + +iskeyword compatible word motions *(easymotion-iskeyword-w)* + *(easymotion-iskeyword-b)* + *(easymotion-iskeyword-bd-w)* + *(easymotion-iskeyword-e)* + *(easymotion-iskeyword-ge)* + *(easymotion-iskeyword-bd-e)* + Default word motions which EasyMotion provide is not completely + compatible with |iskeyword| options. But if you make default word + motion completely compatible with it, there will be so many targets + that they maybe annoy you, so provide |iskeyword| compatible word + motions with another || mappings. + + Example: +> + map w (easymotion-iskeyword-w) + map b (easymotion-iskeyword-b) +< + NOTE: Within line motions are compatible with |iskeyword| by default. Within line motion ~ *easymotion-within-line* @@ -390,28 +418,28 @@ Within line motion ~ range is limited to the current cursor line. (easymotion-wl) *(easymotion-wl)* - This function is same as |(easymotion-w)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-w)|, + except the range is limited to the current cursor line. (easymotion-bl) *(easymotion-bl)* - This function is same as |(easymotion-b)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-b)|, + except the range is limited to the current cursor line. (easymotion-bd-wl) *(easymotion-bd-wl)* - This function is same as |(easymotion-bd-w)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-bd-w)|, + except the range is limited to the current cursor line. (easymotion-el) *(easymotion-el)* - This function is same as |(easymotion-e)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-e)|, + except the range is limited to the current cursor line. (easymotion-gel) *(easymotion-gel)* - This function is same as |(easymotion-ge)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-ge)|, + except the range is limited to the current cursor line. (easymotion-bd-el) *(easymotion-bd-el)* - This function is same as |(easymotion-bd-e)|, except the - range is limited to the current cursor line. + This function is same as |(easymotion-iskeyword-bd-e)|, + except the range is limited to the current cursor line. (easymotion-lineforward) *(easymotion-lineforward)* This function is similar to diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index aea740e..a1d233d 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: t/easymotion_spec.vim " AUTHOR: haya14busa -" Last Change: 12 Feb 2014. +" Last Change: 18 Feb 2014. " Test: https://github.com/kana/vim-vspec " Refer: https://github.com/rhysd/clever-f.vim " Description: EasyMotion test with vim-vspec @@ -242,6 +242,18 @@ describe 'Default settings' Expect maparg('(easymotion-bd-W)', 'v') ==# ':call EasyMotion#WBW(1,2)' " }}} + " Word Motion IsKeyWord: {{{ + Expect maparg('(easymotion-iskeyword-w)', 'n') ==# ':call EasyMotion#WBK(0,0)' + Expect maparg('(easymotion-iskeyword-w)', 'o') ==# ':call EasyMotion#WBK(0,0)' + Expect maparg('(easymotion-iskeyword-w)', 'v') ==# ':call EasyMotion#WBK(1,0)' + Expect maparg('(easymotion-iskeyword-b)', 'n') ==# ':call EasyMotion#WBK(0,1)' + Expect maparg('(easymotion-iskeyword-b)', 'o') ==# ':call EasyMotion#WBK(0,1)' + Expect maparg('(easymotion-iskeyword-b)', 'v') ==# ':call EasyMotion#WBK(1,1)' + Expect maparg('(easymotion-iskeyword-bd-w)', 'n') ==# ':call EasyMotion#WBK(0,2)' + Expect maparg('(easymotion-iskeyword-bd-w)', 'o') ==# ':call EasyMotion#WBK(0,2)' + Expect maparg('(easymotion-iskeyword-bd-w)', 'v') ==# ':call EasyMotion#WBK(1,2)' + " }}} + " End Of Word Motion: {{{ Expect maparg('(easymotion-e)', 'n') ==# ':call EasyMotion#E(0,0)' Expect maparg('(easymotion-e)', 'o') ==# ':call EasyMotion#E(0,0)' @@ -266,6 +278,18 @@ describe 'Default settings' Expect maparg('(easymotion-bd-E)', 'v') ==# ':call EasyMotion#EW(1,2)' " }}} + " End Of Word Motion IsKeyWord: {{{ + Expect maparg('(easymotion-iskeyword-e)', 'n') ==# ':call EasyMotion#EK(0,0)' + Expect maparg('(easymotion-iskeyword-e)', 'o') ==# ':call EasyMotion#EK(0,0)' + Expect maparg('(easymotion-iskeyword-e)', 'v') ==# ':call EasyMotion#EK(1,0)' + Expect maparg('(easymotion-iskeyword-ge)', 'n') ==# ':call EasyMotion#EK(0,1)' + Expect maparg('(easymotion-iskeyword-ge)', 'o') ==# ':call EasyMotion#EK(0,1)' + Expect maparg('(easymotion-iskeyword-ge)', 'v') ==# ':call EasyMotion#EK(1,1)' + Expect maparg('(easymotion-iskeyword-bd-e)', 'n') ==# ':call EasyMotion#EK(0,2)' + Expect maparg('(easymotion-iskeyword-bd-e)', 'o') ==# ':call EasyMotion#EK(0,2)' + Expect maparg('(easymotion-iskeyword-bd-e)', 'v') ==# ':call EasyMotion#EK(1,2)' + " }}} + " JK Motion: {{{ " default Expect maparg('(easymotion-j)', 'n') ==# ':call EasyMotion#JK(0,0)'