hlsearch and unhighlighting

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

hlsearch and unhighlighting

Mark Volkmann
After a search with hlsearch on, how can I unhighlight all the matches without
searching for something else?

--
R. Mark Volkmann
Partner, Object Computing, Inc.
Reply | Threaded
Open this post in threaded view
|

Re: hlsearch and unhighlighting

Tim Chase-2
> After a search with hlsearch on, how can I unhighlight all the
> matches without searching for something else?

If you just want to disable it until the next search, you can use

:noh

If you don't like the behavior at all, you can

:set nohls

For more info, see

:help 'hls'
:he :noh

And, as always, the "set nohls" can be put in your vimrc to make
it persistant.

-tim





Reply | Threaded
Open this post in threaded view
|

Re: hlsearch and unhighlighting

John (Eljay) Love-Jensen
In reply to this post by Mark Volkmann
Hi Mark,

>After a search with hlsearch on, how can I unhighlight all the matches without searching for something else?

:set nohls

--Eljay

Reply | Threaded
Open this post in threaded view
|

Re: hlsearch and unhighlighting

Dave Roberts
In reply to this post by Mark Volkmann
R. Mark Volkmann wrote:

>After a search with hlsearch on, how can I unhighlight all the matches without
>searching for something else?
>
>--
>R. Mark Volkmann
>Partner, Object Computing, Inc.
>
>  
>

I use F3 to turn highlighting on and off with:

:nmap <F3> :set hls!<CR>:set hls?<CR>

- Dave
Reply | Threaded
Open this post in threaded view
|

RE: hlsearch and unhighlighting

Zdenek Sekera
In reply to this post by Mark Volkmann
> -----Original Message-----
> From: Dave Roberts [mailto:[hidden email]]
> Sent: 14 June 2005 16:33
> To: [hidden email]
> Subject: Re: hlsearch and unhighlighting
>
> R. Mark Volkmann wrote:
>
> >After a search with hlsearch on, how can I unhighlight all
> the matches without
> >searching for something else?
> >
> >--
> >R. Mark Volkmann
> >Partner, Object Computing, Inc.
> >
> >  
> >
>
> I use F3 to turn highlighting on and off with:
>
> :nmap <F3> :set hls!<CR>:set hls?<CR>

Or:

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

If you are running older version of vim that doesn't
have <silent> yet, then:

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

(the idea is in both cases to clean the command line.

In both cases simple hitting of <CR> after your search
will clear all matches.

---Zdenek
Reply | Threaded
Open this post in threaded view
|

RE: hlsearch and unhighlighting

Keith Roberts
In reply to this post by Mark Volkmann
>-----Original Message-----
>From: Zdenek Sekera [mailto:[hidden email]]
>Sent: Tuesday, June 14, 2005 7:48 AM
>To: Dave Roberts; [hidden email]
>Subject: RE: hlsearch and unhighlighting
>
>> -----Original Message-----
>> From: Dave Roberts [mailto:[hidden email]]
>> Sent: 14 June 2005 16:33
>> To: [hidden email]
>> Subject: Re: hlsearch and unhighlighting
>>
>> R. Mark Volkmann wrote:
>>
>> >After a search with hlsearch on, how can I unhighlight all
>> the matches without
>> >searching for something else?
>> >
>> >--
>> >R. Mark Volkmann
>> >Partner, Object Computing, Inc.
>> >
>> >  
>> >
>>
>> I use F3 to turn highlighting on and off with:
>>
>> :nmap <F3> :set hls!<CR>:set hls?<CR>
>
>Or:
>
>nnoremap <silent> <CR> :nohlsearch<CR>
>
>If you are running older version of vim that doesn't have
><silent> yet, then:
>
>nnoremap <CR> :nohlsearch<CR>/<BS><CR>
>
>(the idea is in both cases to clean the command line.
>
>In both cases simple hitting of <CR> after your search will
>clear all matches.
>
>---Zdenek

Heh, heh.  I was going to mention this map, which I use all the time
(even crediting you), but I see you beat me to it.

I recently moved the definition of this map to an ftplugin for the
language I use, because it was being changed/undone by something in my
setup when it was a global map in my vimrc:

" Un-hilight search strings with <CR> [in ftplugin so isn't remapped]
        nnoremap <buffer> <CR> :noh<CR>/<BS> " [zdenek]

-Keith

Reply | Threaded
Open this post in threaded view
|

RE: hlsearch and unhighlighting

Zdenek Sekera-2
> >nnoremap <silent> <CR> :nohlsearch<CR>
> >
> >If you are running older version of vim that doesn't have
> <silent> yet,
> >then:
> >
> >nnoremap <CR> :nohlsearch<CR>/<BS><CR>
> >
> >(the idea is in both cases to clean the command line.
> >
> >In both cases simple hitting of <CR> after your search will
> clear all
> >matches.
> >
> >---Zdenek
>
> Heh, heh.  I was going to mention this map, which I use all
> the time (even crediting you), but I see you beat me to it.
>

:-):-)!

> I recently moved the definition of this map to an ftplugin
> for the language I use, because it was being changed/undone
> by something in my setup when it was a global map in my vimrc:
>
> " Un-hilight search strings with <CR> [in ftplugin so isn't remapped]
> nnoremap <buffer> <CR> :noh<CR>/<BS> " [zdenek]

I may do the same...

---Zdenek

Reply | Threaded
Open this post in threaded view
|

editing long string literals in languages without multi-line strings

Andrew Pimlott-2
In reply to this post by Mark Volkmann
I often find myself producing long string literals in languages without
a syntax for multi-line strings.  For example,

    String s = "select column " +
               "from table " +
               "where condition";

This is terribly tedious to edit; not to mention hard to read due to all
the extra punctuation.  A partial solution I use is to write a filter
that transforms an unquoted multi-line string to a properly quoted one
(and back), eg that transforms between

    String s =
        select column
        from table
        where condition
    ;

and

    String s =
    "   select column                           " +
    "   from table                              " +
    "   where condition                         " +
    "";

This lets me edit without worrying about the punctuation, then insert
the punctuation in a relatively unobtrusive way (and later strip it for
re-edit).  But it's still tedious, and the best solution would be for
vim to support editing the latter form directly.  It should ideally
support keeping the trailing punctuation aligned as I edit,
autoformatting and reformatting, and adding the punctuation to new
lines.

I realized this is rather similar to comment handling, except that
comment handling only supports leading comment markers.  If it were
extended to support trailing comment markers (at absolute column
positions), I think I would have everything I need.  How difficult would
it be to add this feature?  I fear it's not easy.

Does anyone have another solution to this problem?

Thanks,
Andrew

PS.  If you are designing a language, please include multi-line strings!
Reply | Threaded
Open this post in threaded view
|

Re: editing long string literals in languages without multi-line strings

Paul-433
I don't know a general solution, but SQLUtilities is good for formatting SQL
statements.

http://www.vim.org/script.php?script_id=492

--

.