Jak sprawić, by vim nie rozświetlał tego, czego szukałeś?

Szukam "nurple" w pliku. Znalazłem, świetnie. Ale teraz każde wystąpienie "nurple" jest renderowane w chorej czerni na żółtym. Na zawsze.

Forever, czyli dopóki nie poszukam czegoś, o czym wiem, że nie zostanie znaleziony, np. "asdhfalsdflajdflakjdf" po prostu tak, aby wyczyścić poprzednie podświetlenie wyszukiwania.

Nie mogę po prostu wcisnąć magicznego klucza, aby zabić pasemka, gdy skończę szukać?

Author: mbac32768, 2008-09-19

14 answers

Włóż to do swojego .vimrc

" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
 152
Author: Lucas S.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-19 03:09:27

:noh (skrót od nohighlight) wystarczy.

 307
Author: Lee H,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-04-17 15:13:35

/lkjasdf zawsze był szybszy niż :noh dla mnie.

 70
Author: jon,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-08 16:18:27

W takim razie wolę to:

map  <F12> :set hls!<CR>
imap <F12> <ESC>:set hls!<CR>a
vmap <F12> <ESC>:set hls!<CR>gv
I dlaczego? Ponieważ włączaprzełącznik: jeśli podświetlenie jest włączone, naciśnięcie F12 wyłącza go. I vica versa. HTH.
 19
Author: Zsolt Botykai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-08 16:17:58
" Make double-<Esc> clear search highlights
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
 18
Author: Andy Lester,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-09 14:38:53

Dodaj następujący wiersz na końcu .vimrc, aby zapobiec całkowitemu podświetleniu:

set nohlsearch
 14
Author: Daniel Bruce,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-16 22:34:34
            *:noh* *:nohlsearch*
:noh[lsearch]       Stop the highlighting for the 'hlsearch' option.  It
            is automatically turned back on when using a search
            command, or setting the 'hlsearch' option.
            This command doesn't work in an autocommand, because
            the highlighting state is saved and restored when
            executing autocommands |autocmd-searchpat|.
            Same thing for when invoking a user function.

Znalazłem go tuż pod :help #, który ciągle uderzam, i który podkreśla wszystkie słowa na bieżącej stronie, tak jak obecny.

 9
Author: Kent Fredric,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-08 16:20:55

Szukam tak często, że uznałem, że przydatne jest odwzorowanie klawisza podkreślenia, aby usunąć podświetlenie wyszukiwania:

nnoremap <silent> _ :nohl<CR>
 4
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-19 06:59:16

Myślę, że najlepszą odpowiedzią jest mieć skrót lidera:

<leader>c :nohl<CR>

Teraz, gdy masz cały dokument z podświetlonymi terminami, po prostu wciskasz, c (mój lider mapuje do przecinka). Działa idealnie.

 4
Author: Daniel Miessler,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-08 18:26:04

Mam to w swoim .vimrc:

nnoremap ; :set invhlsearch<CR>

W ten sposób; przełączy podświetlanie wyszukiwania. Normalnie, klawisz ; powtarza najnowsze Polecenie t/T / f / F, ale tak naprawdę nigdy nie używałem tej funkcji. Uważam to ustawienie za znacznie bardziej użyteczne, ponieważ mogę szybko zmieniać podświetlanie wyszukiwania i wyłączać je i łatwo zorientować się, gdzie są moje wyniki wyszukiwania.

 3
Author: Max Cantor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-19 13:21:26

Myślę, że ta odpowiedź w " vim clear last search " jest lepsza:

:let @/ = ""
 3
Author: nocache,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:55:11

Jest hlsearch i nohlsearch. :help hlsearch dostarczy więcej informacji.

Jeśli chcesz związać F12 aby włączyć / wyłączyć, możesz użyć tego:

map     <F12>   :nohlsearch<CR>
imap    <F12>   <ESC>:nohlsearch<CR>i
vmap    <F12>   <ESC>:nohlsearch<CR>gv
 2
Author: Jeffrey Vanneste,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-08-08 16:19:26

Również, jeśli chcesz mieć toogle i mieć pewność, że podświetlenie zostanie ponownie aktywowane podczas następnego wyszukiwania czegoś, możesz użyć tego

nmap <F12> :set hls!<CR>
nnoremap / :set hls<CR>/
 0
Author: Guillaume,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-25 08:59:41

Dodaję następujące mapowanie do mojego ~/.vimrc

map e/ /sdfdskfxxxxy

I w trybie ESC naciskam e/

 -1
Author: Aman Jain,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-05-01 21:27:04