First column of vim highlighted yellow and won't go away

25

2

I have not defined a user vimrc, OS is redhat 4.6 and after a search and replace the first column in the editor is highlighted yellow and it stays that way as I close and open vim. This is the /etc/vimrc that came on the system. anyone see a bug or a reason it would do that?

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1
endif

set nocompatible    " Use Vim defaults (much better!)
set bs=indent,eol,start     " allow backspacing over everything in insert mode
"set ai         " always set autoindenting on
"set backup     " keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more
            " than 50 lines of registers
set history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if has("autocmd")
  augroup redhat
    " In text files, always limit the width of text to 78 characters
    autocmd BufRead *.txt set tw=78
    " When editing a file, always jump to the last cursor position
    autocmd BufReadPost *
    \ if line("'\"") > 0 && line ("'\"") <= line("$") |
    \   exe "normal! g'\"" |
    \ endif
  augroup END
endif

if has("cscope") && filereadable("/usr/bin/cscope")
   set csprg=/usr/bin/cscope
   set csto=0
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
      cs add cscope.out
   " else add database pointed to by environment
   elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
   endif
   set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

if &term=="xterm"
     set t_Co=8
     set t_Sb=[4%dm
     set t_Sf=[3%dm
endif

Jed Schneider

Posted 2011-02-23T19:42:29.767

Reputation: 363

Answers

47

The reason it does that is because of the

set hlsearch

command and because you apparently searched for ^.. To turn the highlighting off until the next search, execute

:nohl

or just search for something nonsensical, e.g. /alsdfkjslk. To turn the highlighting off permanently, create your own ~/.vimrc and put this in it:

set nohlsearch

garyjohn

Posted 2011-02-23T19:42:29.767

Reputation: 29 085

It's really annoying that the highlight doesn't go away after pressing esc – Deniz – 2017-05-30T15:29:20.793

1yah i did a search for :s/^/#/ to comment out a section – Jed Schneider – 2011-02-23T20:29:47.500

4

The previous search is stored in ~/.viminfo. You can change it in there, or use :nohl to turn it off until the next search.

Ignacio Vazquez-Abrams

Posted 2011-02-23T19:42:29.767

Reputation: 100 516