5

I program with Python and I installed python-mode with pathogen. Everything was fine but then suddenly Vim started highlighting all the dots in the files. And it's kind of frustrating.

I thought it was the plug-in so I deleted everything in my ~/.vimrc. The content on my ~/.vimrc was:

" Pathogen load
filetype off

call pathogen#infect()
call pathogen#helptags()

filetype plugin indent on
syntax on

But nope, it wasn't the plugin: Vim still highlights all the dots. I'll attach an image.

Can you give me a hand with this? I'll appreciate it big time, promise.

vim highlights dots

  • 1
    Is your 'hlsearch' option set? Find out by typing :set hlsearch? in normal mode. – jjaderberg Aug 24 '15 at 19:00
  • jjaderberg might be on the good track: it seems that Vim is highligting matches of the last pattern you searched for. If you make a new search with /new pattern dots will probably not be highligted anymore. In the doc :h hlsearch you can read "When there is a previous search pattern, highlight all its matches" then if :set hlsearch? outputs hlsearch you can use set hlsearch! to disable it. – statox Aug 24 '15 at 20:26
  • Another way for removing the highlight is setting the last search register to empty :let @/ = "" but it will clear your last search not only disable the highlighting. I have this mapping on my .vimrc nnoremap <silent><leader>cs :let @/ = ""<cr> – vappolinario Aug 25 '15 at 14:56
  • @jjaderberg @statox Thank you all for your comments and support! I've learned a lot since I post this question yesterday! Now I have rules on my .vimrc about the highlighting. It was indeed hlsearch. It's funny how something like a search can drive you crazy. @vappolinario I'll try your suggestion too! thanks! – gglasses Aug 25 '15 at 16:56
4

As jjaderberg and statox have mentioned it seems like you have set hlsearch. All . in your file will be highlighted when you search for them directly (/.) or if your cursor is placed on a dot and you press *. The highlighting stays enabled till you either:

  • Perform a new search with /{something}
  • Perform a new search for the word under your cursor with *
  • Disable the current highlighting with :nohlsearch, or short :noh. This leaves search highlighting on in general for your next search.
  • Disable search highlighting completely with :set nohlsearch, or short :set nohl. This disables search highlighting for your next searches. If you want this to be a permanent state, add it to your .vimrc.
  • I added set nohlsearch to my .vimrc and worked like a charm. I did this because I have updated several files since the . appeared highlighted and doing set nohlsearch just turn off the highlighting in the current file. Thank you for the solution and the explanation. – gglasses Aug 24 '15 at 21:02
  • 1
    (I wonder if it's customary (good practice?) to wait for the OP author to confirm the issue (already) raised in the comments and give a chance to one of those authors to place their answers.) – VanLaser Aug 24 '15 at 22:11
  • 2
    Thank you for that hint, you are right. Sorry @jjaderberg and @statox. As you can tell I tried to give credit by linking their name in my answer. I wanted to mention the :noh command which was not mentioned before, but was unable to do so in a comment cause I had too little reputation. – cbaumhardt Aug 24 '15 at 22:40
  • 3
    VanLaser is right I don't know if it is written somewhere but it is a part of the etiquette to let people who made useful comments to make their answers once the OP confirmed the problem is solved. The period without comments ends quickly if you make some good posts so no need to create an answer to add something which should have been a comment. No hard feeling for this time but remember to put respect before point hunting ;-) – statox Aug 24 '15 at 23:38
  • 1
    No worries, I am not. I took your advice as the tip you meant to give and I appreciate it :) – cbaumhardt Aug 25 '15 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.