2

While using Vim for most of my coding, I typically prefer to have the current line under-lined so it's easier to see where I am in my code. I avoid using things like line-highlighting because it usually makes things harder to see with my bright-text-on-dark-background theme (ie: 'torte' colorscheme).

Here is part of my Vim colorscheme:

hi CursorLine    guibg=#0F2130  ctermbg=NONE       cterm=underline
hi CursorColumn  guibg=#0F2130  ctermbg=darkgray   cterm=NONE 

I then enable these features in my .vimrc file (ie: ~/.vimrc).

So, in my case, the current line has a colored underline which is the inverted color of the character above it, while the current column has a dark-grey background, while all other text just has a black background.

The only problem I am having here is that I cannot see underscore ('_') characters while coding because the underline for the current line is the exact same color and thickness as the underscore characters. The only workaround, if its even possible, that would make sense here is to:

  1. Increase the spacing between lines
  2. Make the underline appear a few pixels further below my text

Is anything like this possible in Vim (not gVIM)?

Thank you.

Cloud
  • 18,753
  • 15
  • 79
  • 153
  • 2
    I think `vim` is probably the wrong place to try to solve this. The terminal is in charge of where the underlining would go, and your chosen font is in charge of where the underscore would go. So either fiddle with your font to move the underline or fiddle with your terminal to move the underlining. (I didn't see anything obvious in the `xterm` manpage, which is shocking -- it's way too configurable already and yet still doesn't have an underlining offset switch. Maybe you'll have to fiddle with source. If you're unlucky, it _uses_ underscores for the underlining...) – sarnold Jun 14 '12 at 01:42
  • @sarnold: In order to do that I think it would have to use a Unicode combining character (and I think that's unlikely). – Dennis Williamson Jun 14 '12 at 01:57
  • @Dennis: That _is_ unlikely. Line printers used to print `_^HM` to get an underlined M -- underscore, backspace, M. I believe some terminals even look for this sequence today for the old programs that would generate this content internally... Would `vim` generate these sequences itself via terminfo? Would `xterm` do this itself, print two glyphs together, just to get the height of the underline correct? – sarnold Jun 14 '12 at 02:02
  • @sarnold: I don't know definitive answers to those questions. – Dennis Williamson Jun 14 '12 at 03:11
  • 1
    In GVim, you can try to increase line spacing by setting the `linespace` option (see `:help lsp`). – ib. Jun 14 '12 at 04:27

2 Answers2

4

If you are using gVim:

:hi! def link CursorLine SpellBad

It will use curl-underline.


Changing the linespace to 10+ will display _ above the Cursorline:

:set linespace=10
kev
  • 155,172
  • 47
  • 273
  • 272
0

@kev: +1; It works in gVIM

However, it seems this just can't happen in Vim, as other commenters have noted.

In the end, I just set the background to be dark grey (ie: ctermbg=253), and then set the cursorline to be darker (ie: ctermbg=black cterm=NONE).

From there, I updated my BASHRC file to contain the following: export TERM=xterm-256color

This, of all luck, ends up looking better than my previous colorscheme. I now have a modified version of the standard "slate" color scheme with a very dark gray background (ie: ctermbg=253) while the current line has a solid black background.

Cloud
  • 18,753
  • 15
  • 79
  • 153