From 9f8c26be23e2335e20f7198a4c9d29bd24ed918f Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Mon, 23 Nov 2015 13:12:47 -0800 Subject: don't take over keys by default, require configuration in vimrc fixes #26 --- plugin/camelcasemotion.vim | 54 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) (limited to 'plugin') diff --git a/plugin/camelcasemotion.vim b/plugin/camelcasemotion.vim index 9cae4bd..879972b 100644 --- a/plugin/camelcasemotion.vim +++ b/plugin/camelcasemotion.vim @@ -146,26 +146,13 @@ let g:loaded_camelcasemotion = 1 " We do not provide the fourth "backward to end" motion (,E), because it is " seldomly used. -function! s:CreateMotionMappings() - " Create mappings according to this template: - " (* stands for the mode [nov], ? for the underlying motion [wbe].) - " - " *noremap CamelCaseMotion_? :call camelcasemotion#Motion('?',v:count1,'*') - " if ! hasmapto('CamelCaseMotion_?', '*') - " *map ,? CamelCaseMotion_? - " endif - - for l:mode in ['n', 'o', 'v'] - for l:motion in ['w', 'b', 'e', 'ge'] - let l:targetMapping = 'CamelCaseMotion_' . l:motion - execute l:mode . 'noremap ' . l:targetMapping . ' :call camelcasemotion#Motion(''' . l:motion . ''',v:count1,''' . l:mode . ''')' - - if ! hasmapto(l:targetMapping, l:mode) - execute (l:mode ==# 'v' ? 'x' : l:mode) . 'map ' . l:motion . ' ' . l:targetMapping - endif - endfor +for s:mode in ['n', 'o', 'v'] + for s:motion in ['w', 'b', 'e', 'ge'] + let s:targetMapping = 'CamelCaseMotion_' . s:motion + execute s:mode . 'noremap ' . s:targetMapping . + \ ' :call camelcasemotion#Motion(''' . s:motion . ''',v:count1,''' . s:mode . ''')' endfor -endfunction +endfor " To create a text motion, a mapping for operator-pending mode needs to be " defined. This mapping should move the cursor according to the implemented @@ -177,30 +164,13 @@ endfunction " different behavior depending on whether visual mode has just been entered or " whether text has already been selected. " We deviate from that and always override the existing selection. -function! s:CreateInnerMotionMappings() - " Create mappings according to this template: - " (* stands for the mode [ov], ? for the underlying motion [wbe].) - " - " *noremap CamelCaseMotion_i? :call camelcasemotion#InnerMotion('?',v:count1) - " if ! hasmapto('CamelCaseInnerMotion_i?', '*') - " *map i,? CamelCaseInnerMotion_i? - " endif - for l:mode in ['o', 'v'] - for l:motion in ['w', 'b', 'e', 'ge'] - let l:targetMapping = 'CamelCaseMotion_i' . l:motion - execute l:mode . 'noremap ' . l:targetMapping . ' :call camelcasemotion#InnerMotion(''' . l:motion . ''',v:count1)' - if ! hasmapto(l:targetMapping, l:mode) - execute (l:mode ==# 'v' ? 'x' : l:mode) . 'map i' . l:motion . ' ' . l:targetMapping - endif - endfor +for s:mode in ['o', 'v'] + for s:motion in ['w', 'b', 'e', 'ge'] + let s:targetMapping = 'CamelCaseMotion_i' . s:motion + execute s:mode . 'noremap ' . s:targetMapping . + \ ' :call camelcasemotion#InnerMotion(''' . s:motion . ''',v:count1)' endfor -endfunction - -call s:CreateMotionMappings() -call s:CreateInnerMotionMappings() - -delfunction s:CreateMotionMappings -delfunction s:CreateInnerMotionMappings +endfor " vim: set sts=2 sw=2 expandtab ff=unix fdm=syntax : -- cgit v1.1