Skip to content

Commit

Permalink
Support regex input mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bohrshaw committed Jun 1, 2015
1 parent c3558f8 commit abba2eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion autoload/sneak/search.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ func! sneak#search#new()
" search pattern modifiers (case-sensitivity, magic)
let self.prefix = sneak#search#get_cs(a:input, g:sneak#opt.use_ic_scs).'\V'
" the escaped user input to search for
let self.search = escape(a:input, '"\')
let self.search = a:input =~? '^\\[vm].' ?
\ escape(a:input, '"').'\V' : escape(a:input, '"\')
" example: highlight string 'ab' after line 42, column 5
" matchadd('foo', 'ab\%>42l\%5c', 1)
let self.match_pattern = ''
Expand Down

0 comments on commit abba2eb

Please sign in to comment.