Skip to content

Commit 0e6e475

Browse files
committed
Support regex input mode
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.
1 parent 0f03307 commit 0e6e475

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

autoload/sneak/search.vim

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ func! sneak#search#new()
88
" search pattern modifiers (case-sensitivity, magic)
99
let self.prefix = sneak#search#get_cs(a:input, g:sneak#opt.use_ic_scs).'\V'
1010
" the escaped user input to search for
11-
let self.search = escape(a:input, '"\')
11+
let self.search = a:input =~? '^\\[vm].' ?
12+
\ escape(a:input, '"').'\V' : escape(a:input, '"\')
1213
" example: highlight string 'ab' after line 42, column 5
1314
" matchadd('foo', 'ab\%>42l\%5c', 1)
1415
let self.match_pattern = ''

0 commit comments

Comments
 (0)