mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
defaults: enable 'hlsearch' by default. #2859
Also update the documentation regarding the option. Re: https://github.com/neovim/neovim/issues/2676
This commit is contained in:
@@ -3539,7 +3539,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
See |highlight-default| for the default highlight groups.
|
See |highlight-default| for the default highlight groups.
|
||||||
|
|
||||||
*'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'*
|
*'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'*
|
||||||
'hlsearch' 'hls' boolean (default off)
|
'hlsearch' 'hls' boolean (default on)
|
||||||
global
|
global
|
||||||
{not available when compiled without the
|
{not available when compiled without the
|
||||||
|+extra_search| feature}
|
|+extra_search| feature}
|
||||||
|
@@ -426,18 +426,19 @@ HIGHLIGHTING MATCHES
|
|||||||
While editing a program you see a variable called "nr". You want to check
|
While editing a program you see a variable called "nr". You want to check
|
||||||
where it's used. You could move the cursor to "nr" and use the "*" command
|
where it's used. You could move the cursor to "nr" and use the "*" command
|
||||||
and press "n" to go along all the matches.
|
and press "n" to go along all the matches.
|
||||||
There is another way. Type this command: >
|
|
||||||
|
|
||||||
:set hlsearch
|
Vim will highlight all matches. That is a very good way to see where the
|
||||||
|
variable is used, without the need to type commands.
|
||||||
If you now search for "nr", Vim will highlight all matches. That is a very
|
|
||||||
good way to see where the variable is used, without the need to type commands.
|
|
||||||
To switch this off: >
|
To switch this off: >
|
||||||
|
|
||||||
:set nohlsearch
|
:set nohlsearch
|
||||||
|
|
||||||
Then you need to switch it on again if you want to use it for the next search
|
Then you need to switch it on again if you want to use it for the next search
|
||||||
command. If you only want to remove the highlighting, use this command: >
|
command: >
|
||||||
|
|
||||||
|
:set hlsearch
|
||||||
|
|
||||||
|
If you only want to remove the highlighting, use this command: >
|
||||||
|
|
||||||
:nohlsearch
|
:nohlsearch
|
||||||
|
|
||||||
|
@@ -64,8 +64,6 @@ Now press CTRL-A. The year will be increased by one:
|
|||||||
|
|
||||||
Use "n" to find the next year, and press "." to repeat the CTRL-A ("." is a
|
Use "n" to find the next year, and press "." to repeat the CTRL-A ("." is a
|
||||||
bit quicker to type). Repeat "n" and "." for all years that appear.
|
bit quicker to type). Repeat "n" and "." for all years that appear.
|
||||||
Hint: set the 'hlsearch' option to see the matches you are going to change,
|
|
||||||
then you can look ahead and do it faster.
|
|
||||||
|
|
||||||
Adding more than one can be done by prepending the number to CTRL-A. Suppose
|
Adding more than one can be done by prepending the number to CTRL-A. Suppose
|
||||||
you have this list:
|
you have this list:
|
||||||
|
@@ -34,6 +34,7 @@ these differences.
|
|||||||
- 'complete' doesn't include "i"
|
- 'complete' doesn't include "i"
|
||||||
- 'encoding' defaults to "utf-8"
|
- 'encoding' defaults to "utf-8"
|
||||||
- 'formatoptions' defaults to "tcqj"
|
- 'formatoptions' defaults to "tcqj"
|
||||||
|
- 'hlsearch' is set by default
|
||||||
- 'incsearch' is set by default
|
- 'incsearch' is set by default
|
||||||
- 'langnoremap' is set by default
|
- 'langnoremap' is set by default
|
||||||
- 'mouse' defaults to "a"
|
- 'mouse' defaults to "a"
|
||||||
|
@@ -880,9 +880,9 @@ static vimoption_T
|
|||||||
{"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
|
{"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
|
||||||
(char_u *)&p_hkmapp, PV_NONE,
|
(char_u *)&p_hkmapp, PV_NONE,
|
||||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||||
{"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
|
{"hlsearch", "hls", P_BOOL|P_VIM|P_RALL,
|
||||||
(char_u *)&p_hls, PV_NONE,
|
(char_u *)&p_hls, PV_NONE,
|
||||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
{(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
|
||||||
{"icon", NULL, P_BOOL|P_VI_DEF,
|
{"icon", NULL, P_BOOL|P_VI_DEF,
|
||||||
(char_u *)&p_icon, PV_NONE,
|
(char_u *)&p_icon, PV_NONE,
|
||||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||||
|
@@ -25,7 +25,8 @@ describe('search highlighting', function()
|
|||||||
screen:set_default_attr_ignore( {{bold=true, foreground=hl_colors.NonText}} )
|
screen:set_default_attr_ignore( {{bold=true, foreground=hl_colors.NonText}} )
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is off by default', function()
|
it('is disabled by ":set nohlsearch"', function()
|
||||||
|
execute('set nohlsearch')
|
||||||
insert("some text\nmore text")
|
insert("some text\nmore text")
|
||||||
feed("gg/text<cr>")
|
feed("gg/text<cr>")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -40,13 +41,14 @@ describe('search highlighting', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('works', function()
|
it('works', function()
|
||||||
execute('set hlsearch')
|
|
||||||
insert([[
|
insert([[
|
||||||
some text
|
some text
|
||||||
more textstuff
|
more textstuff
|
||||||
stupidtexttextstuff
|
stupidtexttextstuff
|
||||||
a text word
|
a text word
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
-- 'hlsearch' is enabled by default. #2859
|
||||||
feed("gg/text<cr>")
|
feed("gg/text<cr>")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
some {1:^text} |
|
some {1:^text} |
|
||||||
|
Reference in New Issue
Block a user