aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-02-01 12:35:46 +0100
committerTeddy Wing2020-02-01 12:35:46 +0100
commitac01d7a97118519f49221a49cc25640b2aba7cc8 (patch)
tree125c8da8819fb3d8e8f7348e491c733dbe09447b
downloadvim-searchop-ac01d7a97118519f49221a49cc25640b2aba7cc8.tar.bz2
Draft version of searching for what was selected by a motion
Currently doesn't highlight correctly. Only works in normal mode for now. Overwrites the unnamed register. Inspired by https://github.com/godlygeek/vim-files/blob/8714546/plugin/vsearch.vim
-rw-r--r--plugin/searchop.vim11
1 files changed, 11 insertions, 0 deletions
diff --git a/plugin/searchop.vim b/plugin/searchop.vim
new file mode 100644
index 0000000..6757dcf
--- /dev/null
+++ b/plugin/searchop.vim
@@ -0,0 +1,11 @@
+nnoremap <silent> <leader>a :set opfunc=Search<CR>g@
+vnoremap <silent> <leader>a :<C-u>call Search(visualmode(), 1)<CR>
+
+
+function! Search(type, ...)
+ silent execute "normal! `[v`]y"
+
+ let @/ = escape(@@, '\')
+ call histadd('/', @/)
+ normal! n
+endfunction