nohlsearch with <ESC> like Lazyvim

Signed-off-by: Osamu Aoki <osamu@debian.org>
This commit is contained in:
Osamu Aoki 2024-02-27 20:07:09 +09:00
parent f43210ee44
commit f85a1fc32d

View file

@ -285,6 +285,14 @@ set spelllang=en_us,cjk " :h 'spl -- english spell, ignore CJK</screen>
These are taken from most popular settings
"silent!" is needed to avoid error due to difference of Vim/Nvim
I understand n and N remap may be avoided if scrolloff is big enough but I like it this way.
How to cope with remapped <C-L>
* Vim: <C-L> Clears and redraws the screen with "clear highlight"
* Nvim <C-L> Clears and redraws the screen with "clear highlight" and "diff update"
nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>
* Lazyvim uses: map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", ...)
==> Remap <ESC> like Lazyvim (not exacly as Nvim <C-L> for now)
nnoremap <ESC> <CMD>noh<CR><ESC>
inoremap <ESC> <CMD>noh<CR><ESC>
-->
<screen>""" *** popular mappings ***
""" Window moves without using CTRL-W which is dangerous in INSERT mode
@ -292,6 +300,9 @@ nnoremap &lt;C-H&gt; &lt;C-W&gt;h
nnoremap &lt;C-J&gt; &lt;C-W&gt;j
nnoremap &lt;C-K&gt; &lt;C-W&gt;k
silent! nnoremap &lt;C-L&gt; &lt;C-W&gt;l
""" nohlsearch with <ESC> (<C-L> is mapped as above)
inoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt;
nnoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt;
""" execute macro recorded with &lt;ESC&gt;qq.....&lt;ESC&gt;q with Q
nnoremap Q @q
""" center after jump next