Open haya14busa opened 10 years ago
This feature is for find motions. e.g. <Plug>(easymotion-s)
, <Plug>(easymotion-f)
, etc..
Should I consider filetype
?
Sample?:
let g:EasyMotion_userdict = {
\ '_' : {
\ 'dd' : '\d\+'
\ , '??' : '\v[!"#$%&''()=~|\-^\\@`[\]{};:+*<>,.?_/]+'
\ , 'bb' : '\v[()[\]{}]+'
\ , 'ee' : '[eæœèéêëēėęěə]'
\ , 'ww' : '\(\<.\|^$\)'
\ , '$$' : '$'
\ , 'jk' : '^\(\w\|\s*\zs\|$\)'
\ },
\ 'vim' : {
\ 'fn' : '\<fu\%[nction]!\=\s\+\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\ze\s*('
\ },
\ 'python' : {
\ 'fn' : '^\s*def\s\+\h\w*\s*('
\ }
\ }
My use case is jumping to any punctuation sign by typing an easily reachable wildcard character so I have drafted this feature by introducing proxy symbols dictionary:
let g:EasyMotion_proxy_symbols = {';': '!@#$%^&*()-_=+\|:;''"[]{},<.>?/~'}
I use Coleman layout so ;
is easily reachable for me.
The implementation is trivial for 1-char substitutions, however I see two possible approaches to implementing the 2-char dictionary feature:
g:EasyMotion_user_dict
. Thus you can type exactly 2 characters in easymotion-s2
motion. Typing a 2-char combination from a user-defined dictionary will result in matching only the regex from this dictionary. This approach does not require any processing during user input and could be implemented almost as simply as my 1-char g:EasyMotion_proxy_symbols
dictionary.g:EasyMotion_user_dict
. Thus you can type 3 or even 4 characters before triggering easymotion-s2
motion. Given user dictionary:let g:EasyMotion_userdict = { 'dd' : '\d\+', 'ee' : '[eæœèéêëēėęěə]' }
Typing ddee
will match any digit followed by any e-like character. However there exists no way to distinguish ddee
from dde
apart from triggering motion after some timeout or ENTER
. This approach will require modification of EasyMotion command line processing and may be more challenging to implement. In addition it may lead to ambiguous cases.
@haya14busa Could you please tell me the vision of this feature?
branch: https://github.com/easymotion/vim-easymotion/issues/135#issuecomment-42261158
Thank you for the comment :+1: I have no plan to support more than two character. If you want something like that, use https://github.com/haya14busa/incsearch-easymotion.vim and create pattern converter module for incsearch.vim (e.g. https://github.com/haya14busa/incsearch-fuzzy.vim) n-char search motion considers input as regex, so it's difficult to support user dict feature.
But, we can apply same logic to one-character dict for 2-char search. I prefer 1-character dict also applies to 2-char search.
I already use incsearch-easymotion and incsearch-fuzzy. Thank you very much for excellent plugins!
I also agree with the simplified approach no mater 1-char or 2-char combination is used: it will permit to avoid ambiguity. Thus with:
let g:EasyMotion_userdict = { 'dd' : '\d\+', 'ee' : '[eæœèéêëēėęěə]' }
dd
will be transform into any digit by easymotion-s2
motion.
But how do you imagine using 2-char substitutions in easymotion-f
and easymotion-t
?
Like
migemo
&smartsign
feature.e
-> match anye
like charactersmigemo
dictionary` but I don't know any other languages' one.a
like characters ...nn
-> match anydigits
??
-> match anysigns
(regexp & base idea is borrowed from clever-f)