From b49d25965be039a932264d7e954837405f60d8c9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 5 Feb 2020 01:03:52 +0100 Subject: Search(): Support visual mode and line-oriented Escape newlines so that multiline search works. --- plugin/searchop.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/searchop.vim b/plugin/searchop.vim index a795234..ecfe2a1 100644 --- a/plugin/searchop.vim +++ b/plugin/searchop.vim @@ -5,9 +5,15 @@ vnoremap z/ :call Search(visualmode(), 1) function! Search(type, ...) let user_unnamed_register = @@ - silent execute "normal! `[v`]y" + if a:0 + silent execute "normal! gvy" + elseif a:type == 'line' + silent execute "normal! '[V']y" + else + silent execute "normal! `[v`]y" + endif - let @/ = escape(@@, '\') + let @/ = substitute(escape(@@, '\'), '\n', '\\n', 'g') call histadd('/', @/) call feedkeys('n', 't') -- cgit v1.2.3