gvim搜索后如何取消搜索,不高亮显示

69 views
Skip to first unread message

zhusupe

unread,
Oct 27, 2008, 6:02:03 AM10/27/08
to vim...@googlegroups.com
gvim搜索后,如何取消搜索,不高亮显示? 默认的启动gvim就会进行上次的搜索,并高亮显示。

RedNax

unread,
Oct 27, 2008, 8:50:54 AM10/27/08
to Vim.cn
:nohlsearch
这样会暂时取消高亮,下次搜索打开高亮

:set nohlsearch
可以取消高亮功能,再搜索也不会高亮

zhusupe

unread,
Oct 27, 2008, 10:37:53 AM10/27/08
to Vim...@googlegroups.com
RedNax 于 10/27/2008 08:50 PM http://embed.mibbit.com/?channel=zhusupe 写道:
> :nohlsearch
> 这样会暂时取消高亮,下次搜索打开高亮
>

这样太麻烦,我一般是用/~
> :set nohlsearch
> 可以取消高亮功能,再搜索也不会高亮
>

好了,用了这种方法,搜索的时候虽然没有高亮,但是光标会移动到搜索结果。

Yongwei Wu

unread,
Oct 27, 2008, 10:37:24 AM10/27/08
to Vim...@googlegroups.com
2008/10/27 zhusupe <zhudo...@gmail.com>:

> RedNax 于 10/27/2008 08:50 PM http://embed.mibbit.com/?channel=zhusupe 写道:
>> :nohlsearch
>> 这样会暂时取消高亮,下次搜索打开高亮
>>
>
> 这样太麻烦,我一般是用/~

不麻烦,定义一个快捷键就行:

" Key mapping to stop the search highlight
nmap <silent> <F2> :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>

你的方法在文件中出现了相应的字符串就不行了。而且用nohlsearch的话,需要继续搜索的话按n或N就可以了。你的方法会破坏搜索字串。

>> :set nohlsearch
>> 可以取消高亮功能,再搜索也不会高亮
>>
>
> 好了,用了这种方法,搜索的时候虽然没有高亮,但是光标会移动到搜索结果。
>> On Oct 27, 6:02 pm, zhusupe <zhudogs...@gmail.com> wrote:
>>> gvim搜索后,如何取消搜索,不高亮显示? 默认的启动gvim就会进行上次的搜索,并高亮显示。


--
Wu Yongwei
URL: http://wyw.dcweb.cn/

grandpa

unread,
Oct 27, 2008, 8:57:02 PM10/27/08
to Vim.cn
我的配置是很早以前别人给我的,设置了这个后,打回车就不高亮了。

:nnoremap <CR> :nohlsearch<CR>/<BS><CR>

zhusupe

unread,
Oct 27, 2008, 9:29:43 PM10/27/08
to Vim...@googlegroups.com
好,已经加入配置文件中。

Yongwei Wu

unread,
Oct 28, 2008, 2:55:05 AM10/28/08
to Vim...@googlegroups.com
2008/10/28 grandpa <lxd...@gmail.com>:

> 我的配置是很早以前别人给我的,设置了这个后,打回车就不高亮了。
>
> :nnoremap <CR> :nohlsearch<CR>/<BS><CR>

似乎有点不必要的东西。下面这样不就行了?

:nnoremap <CR> :nohlsearch<CR><CR>

well

unread,
Oct 30, 2008, 10:02:51 AM10/30/08
to Vim.cn
我也来一个:
nmap <silent> <F2> :silent noh<CR>

Lian Cheng

unread,
Nov 3, 2008, 4:37:59 AM11/3/08
to Vim.cn
哈哈,你也在这里~
我的配置:

" Cleans the search hightlights
nmap <silent> <F4> :set invhlsearch<CR>

Vim很多选项都配有一个inv前缀配置用于将对应的开关选项反转,如:

set paste
set nopaste
set invpaste

set hlsearch
set nohlsearch
set invhlsearch

set ignorecase
set noignorecase
set invignorecase

等等。这样就可以省掉一个键盘映射。

Lian Cheng

unread,
Nov 3, 2008, 4:38:40 AM11/3/08
to Vim.cn
哈哈,你也在这里~
我的配置:

" Cleans the search hightlights
nmap <silent> <F4> :set invhlsearch<CR>

Vim很多选项都配有一个inv前缀配置用于将对应的开关选项反转,如:

set paste
set nopaste
set invpaste

set hlsearch
set nohlsearch
set invhlsearch

set ignorecase
set noignorecase
set invignorecase

等等。这样就可以省掉一个键盘映射。

On Oct 28, 2:55 pm, "Yongwei Wu" <wuyong...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages