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 --- autoload/camelcasemotion.vim | 45 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'autoload') diff --git a/autoload/camelcasemotion.vim b/autoload/camelcasemotion.vim index 248ba39..505786d 100644 --- a/autoload/camelcasemotion.vim +++ b/autoload/camelcasemotion.vim @@ -17,7 +17,7 @@ " file creation "- functions ------------------------------------------------------------------" -function! s:Move( direction, count, mode ) +function! s:Move(direction, count, mode) " Note: There is no inversion of the regular expression character class " 'keyword character' (\k). We need an inversion "non-keyword" defined as " "any non-whitespace character that is not a keyword character" (e.g. @@ -64,14 +64,6 @@ function! s:Move( direction, count, mode ) let l:direction = (a:direction == 'w' ? '' : a:direction) - " CamelCase: Jump to beginning of either (start of word, Word, WORD, - " 123). - " Underscore_notation: Jump to the beginning of an underscore-separated - " word or number. - "call search( '\<\|\u', 'W' . l:direction ) - "call search( '\<\|\u\(\l\+\|\u\+\ze\u\)\|\d\+', 'W' . l:direction ) - "call search( '\<\|\u\(\l\+\|\u\+\ze\u\)\|\d\+\|_\zs\(\a\|\d\)\+', 'W' . l:direction ) - " beginning of ... " word | empty line | non-keyword after whitespaces | non-whitespace after word | number | lowercase folowed by capital letter or number | ACRONYM followed by CamelCase or number | CamelCase | ACRONYM | underscore followed by ACRONYM, Camel, lowercase or number call search( '\m\<\D\|^$\|\%(^\|\s\)\+\zs\k\@!\S\|\>\<\|\d\+\|\l\+\zs\%(\u\|\d\)\|\u\+\zs\%(\u\l\|\d\)\|\u\l\+\|\u\@CamelCaseMotion_' . l:motion + execute (l:mode ==# 'v' ? 'x' : l:mode) . + \ 'map ' . a:leader . l:motion . ' ' . l:targetMapping + endfor + endfor + + " Create mappings according to this template: + " (* stands for the mode [ov], ? for the underlying motion [wbe].) + for l:mode in ['o', 'v'] + for l:motion in ['w', 'b', 'e', 'ge'] + let l:targetMapping = 'CamelCaseMotion_i' . l:motion + execute (l:mode ==# 'v' ? 'x' : l:mode) . + \ 'map i' . a:leader . l:motion . ' ' . l:targetMapping + endfor + endfor +endfunction + " vim: set sts=2 sw=2 expandtab ff=unix fdm=syntax : -- cgit v1.1