Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support regex input #104

Open
bohrshaw opened this issue May 13, 2014 · 8 comments · May be fixed by #105
Open

Support regex input #104

bohrshaw opened this issue May 13, 2014 · 8 comments · May be fixed by #105

Comments

@bohrshaw
Copy link
Contributor

With regex input supported, for example, these jumps would be possible:

" Alternative searching, flexibility improved
nnoremap g/ :call sneak#wrap('', 99, 0, 2, 1)<CR>\v
" Jump around word boundaries, accuracy improved
nnoremap \\w :call sneak#wrap('', 4, 0, 2, 1)<CR>\v<
bohrshaw added a commit to bohrshaw/vim-sneak that referenced this issue May 13, 2014
Fix justinmk#104. This should support more flexibility in customisation. With
this option enabled, only input text not containing "\v, \V, \m, \M" are
treated literal.
@bohrshaw bohrshaw linked a pull request May 13, 2014 that will close this issue
@justinmk
Copy link
Owner

Thank you! What are some example inputs that you use? I can use those examples to add some tests.

bohrshaw added a commit to bohrshaw/vim-sneak that referenced this issue May 14, 2014
Fix justinmk#104. This should support more flexibility in customisation. With
this option enabled, input text not matching '^\\[vVmM].' are still
treated literal.
@bohrshaw
Copy link
Contributor Author

I suppose the the pattern parsing is correct. But there are probably problems when inputting patterns in vmap, omap or in streak mode. Additional integration would be done.

My initial intention for adding pattern input is that, by defining specific mappings, we can jump to common text objects, which is currently all I need. I define a simple wrapper function and some mappings which seems work well.

function! Sneak(pre, post, reverse)
  let n = getchar()
  if n == 27 | return | endif
  let c = nr2char(n)
  call sneak#to('', a:pre.c.a:post, 1, 1, 0, a:reverse, 2, 0)
endfunction
nnoremap <silent> 8w  :call Sneak('\v<',      '',       0)<CR>
nnoremap <silent> 8b  :call Sneak('\v<',      '',       1)<CR>
nnoremap <silent> 8e  :call Sneak('\v',       '>',      0)<CR>
nnoremap <silent> 8ge :call Sneak('\v',       '>',      1)<CR>
nnoremap <silent> 9w  :call Sneak('\v\_s\zs', '',       0)<CR>
nnoremap <silent> 9b  :call Sneak('\v\_s\zs', '',       1)<CR>
nnoremap <silent> 9e  :call Sneak('\v',       '\ze\_s', 0)<CR>
nnoremap <silent> 9ge :call Sneak('\v',       '\ze\_s', 1)<CR>

@justinmk

This comment has been minimized.

@bohrshaw

This comment has been minimized.

bohrshaw added a commit to bohrshaw/vim-sneak that referenced this issue Feb 7, 2015
Prefix input text with '\v', '\m' or '\M' to turn on "regex mode".

This doesn't break search of "literal text" whose length is less than 3.
Because only text matching '^\\[vVmM].' are not literal any more, which
is identical to what "literal text" means in Vim search pattern starting
with '\V'.

Systemic adjustments are needed for utilizing "regex mode", which is
better to be served by the author.

Close justinmk#104.
@bohrshaw

This comment has been minimized.

@justinmk

This comment has been minimized.

@bohrshaw

This comment has been minimized.

@bohrshaw

This comment has been minimized.

bohrshaw added a commit to bohrshaw/vim-sneak that referenced this issue May 17, 2015
Prefix input text with '\v', '\m' or '\M' to turn on "regex mode".

This doesn't break search of "literal text" whose length is less than 3.
Because only text matching '^\\[vVmM].' are not literal any more, which
is identical to what "literal text" means in Vim search pattern starting
with '\V'.

Systemic adjustments are needed for utilizing "regex mode", which is
better to be served by the author.

Close justinmk#104.
bohrshaw added a commit to bohrshaw/vim-sneak that referenced this issue Jun 1, 2015
Prefix input text with '\v', '\m' or '\M' to turn on "regex mode".

This doesn't break search of "literal text" whose length is less than 3.
Because only text matching '^\\[vVmM].' are not literal any more, which
is identical to what "literal text" means in Vim search pattern starting
with '\V'.

Systemic adjustments are needed for utilizing "regex mode", which is
better to be served by the author.

Close justinmk#104.
@justinmk justinmk changed the title Support optional regex input to allow additional customisation Support regex input Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants