You are not logged in.

#1 2009-02-06 03:31:49

horsecool
Member
Registered: 2008-12-22
Posts: 55

vim search

Hi, I am a quite new user of Vim. I found one feather pretty annoying: when I edit tex file using vim-latex, if I type $$ or insert an equation environment by F5, vim will highlight the search result I did last time. Does anyone has the same problem?

Thanks!

Offline

#2 2009-02-06 03:42:02

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: vim search

*chuckles* that one bugged me as well!
Check if you are actually using 'vi' or 'vim'. Often 'vi' is just a link to 'vim'
If you actually use 'vim', then /usr/share/vim/vimrc_example.vim is your friend.
Copy it to your home directory as .vimrc as edit it to turn off 'hlsearch' - I think it says 'hlsearch on' somewhere.

If you are using 'vi', then /etc/virc or EXINIT="..." in your .bashrc

Offline

#3 2009-02-06 03:42:54

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: vim search

If you want to turn off highlight search, put "set nohls" in your .vimrc


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#4 2009-02-06 05:24:35

horsecool
Member
Registered: 2008-12-22
Posts: 55

Re: vim search

thanks for the response!

Is there another way to solve it without turn off highlight search? I know I asked too much, but my friend told me that nothing is impossible with Vim...

hehe, just kidding. I can live without highlight search. smile

Offline

#5 2009-02-06 05:47:38

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: vim search

Sorry, I cant answer that.
Personally the colours bug me no end, so I turn off syntax as well.

Offline

#6 2009-02-06 08:44:31

Damnshock
Member
From: Barcelona
Registered: 2006-09-13
Posts: 414

Re: vim search

horsecool wrote:

thanks for the response!

Is there another way to solve it without turn off highlight search? I know I asked too much, but my friend told me that nothing is impossible with Vim...

hehe, just kidding. I can live without highlight search. smile

You can bind another key sequence to that action (don't ask me how because I don't know, I just know it's possible wink )


My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org

Offline

#7 2009-02-06 13:22:40

addox
Member
From: Leeds, UK
Registered: 2008-08-06
Posts: 6

Re: vim search

You can map the function in .vimrc like this

map <F5> :set hls!<bar>set hls?<CR>

Everytime you press F5 will (de)activate the highlighting. Obviously you can change the key to whatever you want.

P.S. This will only work in normal mode.

Last edited by addox (2009-02-06 13:25:27)

Offline

#8 2009-02-06 15:23:54

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: vim search

Here is what I use:
set nohls
set incsearch
set showmatch

This gives me highlighting while I'm typing in the search, but not after I hit <enter>


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#9 2009-02-06 19:55:47

thisperishedmin
Member
Registered: 2008-11-04
Posts: 164

Re: vim search

addox wrote:

You can map the function in .vimrc like this

map <F5> :set hls!<bar>set hls?<CR>

Everytime you press F5 will (de)activate the highlighting. Obviously you can change the key to whatever you want.

P.S. This will only work in normal mode.

just to clarify... does normal mode mean command mode, or the insert mode?

or is my vim knowledge painfull wrong and there is a whole other mode sad? lol

Offline

#10 2009-02-06 20:29:29

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: vim search

thisperishedmin wrote:
addox wrote:

You can map the function in .vimrc like this

map <F5> :set hls!<bar>set hls?<CR>

Everytime you press F5 will (de)activate the highlighting. Obviously you can change the key to whatever you want.

P.S. This will only work in normal mode.

just to clarify... does normal mode mean command mode, or the insert mode?

or is my vim knowledge painfull wrong and there is a whole other mode sad? lol

command mode is when you press ":" insert mode is when you press "i".  normal mode is after you've hit "esc" repeatedly.  it's also the mode you'd use the dd, yy, p, u, etc commands for text manipulating

Offline

#11 2009-02-12 22:34:47

horsecool
Member
Registered: 2008-12-22
Posts: 55

Re: vim search

I copied this from somewhere I forgot. It's useful if you want to use highligh search.

" press space to turn off highlighting and clear any message already displayed.
:noremap <silent> <space> :silent noh<bar>echo<cr>

thanks for all your response!

Offline

#12 2009-02-12 22:53:06

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: vim search

I noticed a similar issue with :s and hlsearch

:5,10s/^/#/

Will cause the first character of EVERY line to light up. :s shouldn't highlight anything at all if you ask me.

Offline

Board footer

Powered by FluxBB