Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I customize the line highlight color in Vim CtrlP?

Tags:

vim

colors

ctrlp

When I'm using the Vim plugin CtrlP I have a hard time seeing which file is being highlighted as the current file I might open. I want the highlight line to be bright and vivid.

I could change the color of my CursorLine setting but I don't want it to change everywhere. When I'm normally editing files I want my highlight cursor line to be a subtle background-ish color.

How can I change the color of only the highlight line in the CtrlP file selection buffer?

like image 512
bryan kennedy Avatar asked Feb 12 '23 18:02

bryan kennedy


1 Answers

I got a lead on a fix in this GitHub issue asking a similar question.

CtrlP offers a setting called ctrlp_buffer_func that lets you set a function to call every time CtrlP is loaded and when it exits. In my .vimrc file, I just set the highlight color to a bright and vivid color on CtrlP load, and then set it back to my default when I exit CtrlP.

let g:ctrlp_buffer_func = { 'enter': 'BrightHighlightOn', 'exit':  'BrightHighlightOff', }

function BrightHighlightOn()
  hi CursorLine guibg=darkred
endfunction

function BrightHighlightOff()
  hi CursorLine guibg=#191919
endfunction
like image 168
bryan kennedy Avatar answered Mar 15 '23 00:03

bryan kennedy