From b4c7b84b9c0d4af538b0f5cfdef4e3bb3dc40d61 Mon Sep 17 00:00:00 2001 From: Henrik Nyh Date: Sat, 16 Mar 2013 10:20:25 +0100 Subject: Consider "-" a separator just like "_". This means you can do `set iskeyword+=-` to autocomplete including dashes, but still use CamelCaseMotion for the subparts. --- autoload/camelcasemotion.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/camelcasemotion.vim b/autoload/camelcasemotion.vim index a0e8e14..d327ab2 100644 --- a/autoload/camelcasemotion.vim +++ b/autoload/camelcasemotion.vim @@ -32,7 +32,7 @@ function! s:Move( direction, count, mode ) "call search( '\>\|\(\a\|\d\)\+\ze_', 'We' ) " end of ... " number | ACRONYM followed by CamelCase or number | CamelCase | underscore_notation | non-keyword | word - call search( '\d\+\|\u\+\ze\%(\u\l\|\d\)\|\l\+\ze\%(\u\|\d\)\|\u\l\+\|\%(\a\|\d\)\+\ze_\|\%(\k\@!\S\)\+\|\%(_\@!\k\)\+\>', 'We' ) + call search( '\d\+\|\u\+\ze\%(\u\l\|\d\)\|\l\+\ze\%(\u\|\d\)\|\u\l\+\|\%(\a\|\d\)\+\ze[-_]\|\%(\k\@!\S\)\+\|\%([-_]\@!\k\)\+\>', 'We' ) " Note: word must be defined as '\k\>'; '\>' on its own somehow " dominates over the previous branch. Plus, \k must exclude the " underscore, or a trailing one will be incorrectly moved over: @@ -74,7 +74,7 @@ function! s:Move( direction, count, mode ) "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 | ACRONYM followed by CamelCase or number | CamelCase | underscore followed by ACRONYM, Camel, lowercase or number - call search( '\<\D\|^$\|\%(^\|\s\)\+\zs\k\@!\S\|\>\S\|\d\+\|\u\+\ze\%(\u\l\|\d\)\|\u\l\+\|_\zs\%(\u\+\|\u\l\+\|\l\+\|\d\+\)', 'W' . l:direction ) + call search( '\<\D\|^$\|\%(^\|\s\)\+\zs\k\@!\S\|\>\S\|\d\+\|\u\+\ze\%(\u\l\|\d\)\|\u\l\+\|[-_]\zs\%(\u\+\|\u\l\+\|\l\+\|\d\+\)', 'W' . l:direction ) " Note: word must be defined as '\<\D' to avoid that a word like " 1234Test is moved over as [1][2]34[T]est instead of [1]234[T]est " because \< matches with zero width, and \d\+ will then start -- cgit v1.1