You are not logged in.

#1 2011-08-25 01:16:07

dodo3773
Member
Registered: 2011-03-17
Posts: 818

[SOLVED] Keep highlighting when next search result picked vim

I recently started using vim and I like it a lot. I have searched around and found a lot of places that talk about highlighting all search results - this is not what I want. My question is that when I do a search the first item that matches (while typing) is highlighted. But then when I hit "enter" the cursor jumps to the next position but the highlighting turns off. Is there any way to keep highlighting on after hitting "enter"? So that when I hit "n" the next match in front of the cursor is highlighted? Maybe until going into insert mode or something. Here is my .vimrc

set background=dark
set t_Co=256
set wrap
set display=lastline
syntax on
set number
set mouse=a
hi LineNr ctermfg=grey
set nocompatible
set incsearch 

set virtualedit=onemore
map <C-c> :q

Last edited by dodo3773 (2011-08-25 02:11:11)

Offline

#2 2011-08-25 01:38:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Keep highlighting when next search result picked vim

You are looking for hlsearch


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2011-08-25 01:43:31

dodo3773
Member
Registered: 2011-03-17
Posts: 818

Re: [SOLVED] Keep highlighting when next search result picked vim

jasonwryan wrote:

You are looking for hlsearch

I tried "set hlsearch" But then they all highlight. Is there any way to just highlight the one that the mouse cursor is on?

Offline

#4 2011-08-25 01:46:34

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Keep highlighting when next search result picked vim

That's in your colour scheme: the hl colour should be different from your cursor colour - that way you can see both the other matches and also your current selection.

# edit: in case I missed your point: if it only highlights where your cursor is, how will you tell where else the search is returned in your window?

Last edited by jasonwryan (2011-08-25 01:47:55)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2011-08-25 01:50:18

dodo3773
Member
Registered: 2011-03-17
Posts: 818

Re: [SOLVED] Keep highlighting when next search result picked vim

jasonwryan wrote:

That's in your colour scheme: the hl colour should be different from your cursor colour - that way you can see both the other matches and also your current selection.


I use the I-Beam cursor instead of Block cursor. Sorry, I should have mentioned that. Basically what I am trying to do is when I go to the next match only highlight that next match not all of them at once. Do you know if this is possible?

Offline

#6 2011-08-25 02:04:14

dodo3773
Member
Registered: 2011-03-17
Posts: 818

Re: [SOLVED] Keep highlighting when next search result picked vim

jasonwryan wrote:

# edit: in case I missed your point: if it only highlights where your cursor is, how will you tell where else the search is returned in your window?

By going to the next matching expression. I just want to see them highlighted one at a time. Maybe it is not possible I am not sure. I am very new to vim.

Offline

#7 2011-08-25 02:04:26

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Keep highlighting when next search result picked vim

I don't think so: the only thing I can suggest is toggling the highlights:

" space bar un-highligts search
:noremap <silent> <Space> :silent noh<Bar>echo<CR>

Last edited by jasonwryan (2011-08-25 02:05:09)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2011-08-25 02:10:47

dodo3773
Member
Registered: 2011-03-17
Posts: 818

Re: [SOLVED] Keep highlighting when next search result picked vim

jasonwryan wrote:

I don't think so: the only thing I can suggest is toggling the highlights:

" space bar un-highligts search
:noremap <silent> <Space> :silent noh<Bar>echo<CR>

Very cool. I will use this for sure. Thanks.

I guess the answer to my question is no though. What I was looking for is not an available feature yet. Marking thread as solved.

Offline

Board footer

Powered by FluxBB