From 59061b5433a587da04702afee234980fb6b4b349 Mon Sep 17 00:00:00 2001 From: Bohr Shaw Date: Tue, 13 May 2014 12:54:40 +0800 Subject: [PATCH] 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 #104. --- autoload/sneak/search.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/sneak/search.vim b/autoload/sneak/search.vim index e2a0d45..64783c0 100644 --- a/autoload/sneak/search.vim +++ b/autoload/sneak/search.vim @@ -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 = ''