Wednesday, March 28, 2012

Re: cursorline and long lines

On Wed, March 28, 2012 19:52, Abu Yoav wrote:
> I've just started using vim, and enjoy it very much. I've searched a
> bit, but could not find an answer to the following. So, if this is
> obvious, excuse the newbie...
>
> I am editing a text file (latex). I prefer that each paragraph be a
> long line, and that vim wrap the text. That's the usual behaviour, and
> that works fine. An option that seems very helpful is cursorline, so I
> set it (":set cul"). However, this does not do what I want. Namely,
> instead of highlighting the *visual* line I am on, it highlights the
> whole paragraph. Is there any way to highlight only the current visual
> line I am on? Again, a workaround would be to instruct vim to have
> lines of at most 80 characters (say), but I don't want that.

Hm, the documentation for 'cul' talks about screenlines, but in my
experience, 'cul' has always been highlighting complete lines. Looks like
a documentation error.
I guess, there is nothing you can do about, except, maybe implement it
yourself:

fu! CursorLine()
if !exists("CL")
hi CL gui=underline term=underline cterm=underline
endif
if !exists("b:matches")
let b:matches = 0
endif
let col = virtcol('.')
let width = winwidth(0)
let screenline = col/width
let start = screenline * width
let end = (screenline+1) * width + 1
if b:matches > 0
sil! call matchdelete(b:matches)
endif
let pat = '\%'. line('.'). 'l\%>'. start. 'v.*\%<'. end. 'v'
let b:matches = matchadd('CL', pat)
endfu
au CursorHold,CursorHoldI * :call CursorLine()

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: