标签云

微信群

扫码加入我们

WeChat QR Code


possible duplicate of Vim clear last search highlighting

2018年10月22日08分38秒

/<mash keyboard>

1970年01月01日00分07秒

Definitely a duplicate of stackoverflow.com/questions/657447/… and should be closed to direct people there

2018年10月21日08分38秒

BenCreasy why would one call an older post a duplicate of a newer one?

2018年10月21日08分38秒

Ruslan that one has nearly 10 times as many upvotes and they're both pretty old ('08 and '09)

2018年10月21日08分38秒

Oooh, that's a goodie. I've been using /<ENTER> which works as long as there's no in my files. I must modify my vimrc NOW!

2018年10月21日08分38秒

This is great, cured a lot of my headaches! I think ,it's better to use the full command in vimrc (:nohlsearch) to avoid conflicts in future.

2018年10月22日08分38秒

<leader>c :nohl<CR> is a better option, I think.

2018年10月21日08分38秒

trillions - ctrl-l will only work if you start vim after editing .vimrc as shown.

2018年10月21日08分38秒

Thats what I had been looking for even after 6 years. May be too late. :)

2018年10月22日08分38秒

Fear not, the highlighting returns with the next search. The command should probably be named clearhighlight.

2018年10月22日08分38秒

Four years late, but thanks. This is good stuff.

2018年10月22日08分38秒

kmarks2 see you next leap year, I guess?

2018年10月22日08分38秒

Just clarifying steamer25's comment. :set nohlsearch turns off search highlighting completely :nohlsearch or :noh will clear the current highlight, but leave you in hlsearch mode for the next search.

2018年10月22日08分38秒

Doing this in front of someone who knew Vim better than I did is how I learned about :nohls.

2018年10月22日08分38秒

That's gross! It adds lkjasdf to your search history.

2018年10月22日08分38秒

then make :noh faster for you: nnoremap <leader>h :noh<cr>

2018年10月22日08分38秒

Can't you just program vim to never include lkjasdf in the search history? Though, no, wait, that would be more of an Emacs solution...

2018年10月21日08分38秒

i came to the same conclusion, years ago, thanks mate

2018年10月22日08分38秒

This can also be accomplished with the "invhlsearch" setting.

2018年10月22日08分38秒

I like this, but I think your i mapping would be better with gi instead of a. Either that or <C-o>:set hls!<CR>.

2018年10月21日08分38秒

but F12 is my yakuake key :(

2018年10月21日08分38秒

Why is this not higher rated, this is simpler and more intuitive than a lot of the methods above.

2018年10月21日08分38秒

Love this! Thanks!

2018年10月21日08分38秒

Two questions: 1. why is the 2nd <Esc> necessary in the replacement? 2. do you know how to (temporarily) disable the escape bell for this?

2018年10月21日08分38秒

On a side note, it's weird that one has to :noh to turn off search highlighting while instead of :hlsearch one has to set hlsearch to turn it on again. (I guess I should't be surprised at vim "weirdiness"...)

2018年10月22日08分38秒

map <leader>c :nohl<CR> would be what you need in vimrc.

2018年10月21日08分38秒

nnoremap <silent> <C-l> :let /=""<CR>

2018年10月22日08分38秒