Add smartsign feature like smartcase
Now, you can jump to '!' by '1'. Option: keyboard layout g:EasyMotion_use_smartsign_us g:EasyMotion_use_smartsign_jp
This commit is contained in:
parent
9185b1362a
commit
4c55ab61ac
@ -339,7 +339,7 @@ endfunction "}}}
|
||||
|
||||
function! s:findMotion(char) "{{{
|
||||
" Find Motion: S,F,T
|
||||
let re = escape(a:char, '.$^~')
|
||||
let re = escape(a:char, '.$^~\')
|
||||
|
||||
if g:EasyMotion_use_migemo
|
||||
let re = s:convertMigemo(re)
|
||||
@ -362,12 +362,43 @@ endfunction "}}}
|
||||
return re
|
||||
endfunction "}}}
|
||||
function! s:convertSmartcase(re, char) "{{{
|
||||
if a:char =~# '\v\U'
|
||||
let re = '\c' . a:re
|
||||
else
|
||||
let re = '\C' . a:re
|
||||
let re = a:re
|
||||
if a:char =~# '\U' "nonuppercase
|
||||
if s:useSmartsign()
|
||||
let re = s:convertSmartsign(a:re, a:char)
|
||||
endif
|
||||
|
||||
return '\c' . re
|
||||
else "uppercase
|
||||
return '\C' . re
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:convertSmartsign(re, char) "{{{
|
||||
let smart_dict = s:load_smart_dict()
|
||||
let upper_sign = escape(get(smart_dict, a:char, ''), '.$^~')
|
||||
if upper_sign ==# ''
|
||||
return a:re
|
||||
else
|
||||
let re = a:re . '\|' . upper_sign
|
||||
return re
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:useSmartsign() "{{{
|
||||
if exists('g:EasyMotion_use_smartsign_us') ||
|
||||
\ exists('g:EasyMotion_use_smartsign_jp')
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:load_smart_dict() "{{{
|
||||
if exists('g:EasyMotion_use_smartsign_us')
|
||||
return g:EasyMotion#sticky_table#us
|
||||
elseif exists('g:EasyMotion_use_smartsign_jp')
|
||||
return g:EasyMotion#sticky_table#jp
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
return re
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
23
autoload/EasyMotion/sticky_table.vim
Normal file
23
autoload/EasyMotion/sticky_table.vim
Normal file
@ -0,0 +1,23 @@
|
||||
" Saving 'cpoptions' {{{
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
" }}}
|
||||
"
|
||||
let EasyMotion#sticky_table#us = {
|
||||
\',' : '<', '.' : '>', '/' : '?',
|
||||
\'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%',
|
||||
\'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+',
|
||||
\';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|',
|
||||
\}
|
||||
|
||||
let EasyMotion#sticky_table#jp = {
|
||||
\',' : '<', '.' : '>', '/' : '?',
|
||||
\'1' : '!', '2' : '"', '3' : '#', '4' : '$', '5' : '%',
|
||||
\'6' : '&', '7' : "'", '8' : '(', '9' : ')', '0' : '_', '-' : '=', '^' : '~',
|
||||
\';' : '+', ':' : '*', '[' : '{', ']' : '}', '@' : '`', '\' : '|',
|
||||
\}
|
||||
|
||||
" Restore 'cpoptions' {{{
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" }}}
|
Loading…
x
Reference in New Issue
Block a user