How do I highlight the current line and the cursor in .vimrc?
You have to change the color of your cursor line to a color other than the color of your cursor. If you're in a terminal emulator like st
or rxvt
, Vim cannot change the color of your cursor; it will always be the color your terminal application decides to make it. Only the graphical version of Vim is able to change the color of your cursor.
You can change your cursor color through your terminal configuration though.
Some ~/.Xdefaults
/ ~/.Xresources
examples:
XTerm*cursorColor: #FFFFFF
URxvt.cursorColor: white
You could also use the Vim command :set cursorcolumn
to put your cursor in crosshairs.
If you do not want to enter the command each time you start Vim, you have to put the commands in your .vimrc
file.
whereis vim
*#type in your linux terminal*
(you'll have a different location, but your color scheme will be here /usr/share/vim/vim74/colors/
.
You can list the existing color schemes with
ls /usr/share/vim/vim74/colors/
try different color schemes from the listed
:colorscheme desert
:colorscheme delek
The following command in Vim activates a vertical line at the cursor's location.
set cursorcolumn
hi CursorColumn ctermbg=8
to toggle (with the exclamation mark, works with all set-command)
set cursorcolumn!
for example:
set cursorline
set cursorline!
hi CursorLine ctermbg=235
*#defines a gray colour for the horizontal line*
Here is a table with xterm colours: link
Use a number by defining ctermbg=...
(... = color number from the table)
You can also try ctermfg=...
, but it's not worth using it.