I have tried to look at other answers here on SO and Google but none of them seem to be changing my cursor settings. I am wanting to have a background of yellow with foreground of white bold but can't get it with the settings that I have seen around the web. I am using MacVim mvim in iTerm2.
Thank you for any help.
Simply putting :set cursorline in your vimrc will highlight the current line in every window and update the highlight as the cursor moves. With the default backslash leader key, typing \c will toggle highlighting on and off. That makes it easy to locate the cursor after scrolling in a large file.
The ctermfg=white is used to set the foreground color to white in a terminal text editor. Finally, the ctermbg=black is used to set the background color to black in a terminal text editor.
If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.
Most likely you are interested in these three highlighting groups: Cursor
, CursorColumn
and CursorLine
. The names are self explanatory.
For example to change just the cursor color:
:highlight Cursor ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold
To do the same for column cursor:
:highlight CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold
If you also need to highlight the current line, use CursorLine
.
If you wants to keep it enable always put the below things in your .vimrc or .gvimrc file
for cursorline
set cursorline
autocmd InsertEnter * highlight CursorLine guibg=#000050 guifg=fg
autocmd InsertLeave * highlight CursorLine guibg=#004000 guifg=fg
for cursor column
set cursorcolumn
autocmd InsertEnter * highlight CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold
autocmd InsertLeave * highlight CursorColumn ctermfg=Black ctermbg=Yellow cterm=bold guifg=Black guibg=yellow gui=NONE
You can change the colors in your wish
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With