diff options
| author | Josh Rahm <rahm@google.com> | 2025-04-10 19:14:10 +0000 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2025-11-07 21:01:15 +0000 |
| commit | 4195ef571e28869e25427cd09700d2691fd0bd9f (patch) | |
| tree | e0ea564132e52256056af6a30aac2a89c1cbbcc8 | |
| parent | 3d8bbb1cb2e84642b8423aaa823827e7ceec58cf (diff) | |
| download | config.vim-4195ef571e28869e25427cd09700d2691fd0bd9f.tar.gz config.vim-4195ef571e28869e25427cd09700d2691fd0bd9f.tar.bz2 config.vim-4195ef571e28869e25427cd09700d2691fd0bd9f.zip | |
Change how clearing highlighting works after InsertLeave.
When using feedkeys(), it was causing problems with Ctrl-O in insert.
Now it disables hlsearch, and reenables it when searching or using n/N.
| -rw-r--r-- | init.vim | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -166,10 +166,8 @@ augroup InitVim au! " Automatically stop highligting things when leaving insert mode. If I want " the highlight back, I can just hit 'n' and it will come back. - " - " I don't know why it can't just be 'noh' and why I have to do this feedkeys - " nonsense, but there appears to be a bug of some kind. - autocmd InsertLeave * call feedkeys("\<cmd>noh\<cr>") + autocmd InsertLeave * set nohlsearch | redraw + autocmd CmdlineEnter /,\? set hlsearch autocmd TextYankPost * \ lua require'vim.hl'.on_yank( @@ -178,6 +176,8 @@ augroup InitVim " autocmd CursorHoldI * lua vim.lsp.buf.document_highlight() " autocmd CursorMoved * lua vim.lsp.buf.clear_references() augroup END +nnoremap <silent> n <cmd>set hlsearch<CR>n +nnoremap <silent> N <cmd>set hlsearch<CR>N " Local configuration that can be set by hostname or just a local configuration. " Local files are ignored by .gitignore so they won't be added to the repo, |