I'm running the command


to block comment a section of code, however, after running the command the editor highlights the first character in every line of the file. I guess this doesn't surprise me since those characters match the regex, but I thought this would be suppressed if I add a range.


Standing on the shoulders of giants

I would highly recommend commenting plugin like commentary (which I use), Nerd Commenter, EnhCommentify, tComment, ..., etc. There is no shame in using a plugin.

  • so far commentary is very useful, thanks for the suggestion.
    – toweleeele
    Jul 30 '15 at 19:45

:.,.5norm I! is an alternative that doesn't use substitution.

By the way, you can shorten your original command like this:


,or like that:


Also, I don't know if you are aware of that but you can prepend your ex command with a count to automatically insert the right range:




And this is yet another way:


But yeah, use commentary.


After performing a search, you can hide the highlights by running


which is short for :nohlsearch. After your next search, the highlights will re-appear.

I actually have this mapped to Ctrl-L so it's even easier to perform.

nmap <silent> <C-L> <C-L>:nohlsearch<CR>:match<CR>:diffupdate<CR>

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.