diff options
author | Teddy Wing | 2020-02-04 22:00:32 +0100 |
---|---|---|
committer | Teddy Wing | 2020-02-04 22:00:32 +0100 |
commit | 15fca46f502c541041788f96512f8a1a92b7fd57 (patch) | |
tree | 0814fbdbfb1bf42044ac2e0be8661d135486da09 | |
parent | ac01d7a97118519f49221a49cc25640b2aba7cc8 (diff) | |
download | vim-searchop-15fca46f502c541041788f96512f8a1a92b7fd57.tar.bz2 |
Search(): Use `feedkeys` instead of `normal!` to advance search
Because of `:h function-search-undo`, using `normal! n` at the end of
the function doesn't highlight the matches with 'hlsearch' (though it
does advance to the next match).
I've seen other mappings that add a `/<CR>` or `n` to the end of the
mapping, but that doesn't work here because it's an operator, so `g@`
needs to be the last thing in the mapping. And I was reluctant to work
out how to make it an `<expr>` mapping.
Fortunately, search highlighting works when `n` is used with
`feedkeys()`.
-rw-r--r-- | plugin/searchop.vim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/plugin/searchop.vim b/plugin/searchop.vim index 6757dcf..41f0f6d 100644 --- a/plugin/searchop.vim +++ b/plugin/searchop.vim @@ -7,5 +7,6 @@ function! Search(type, ...) let @/ = escape(@@, '\') call histadd('/', @/) - normal! n + + call feedkeys('n', 't') endfunction |