Stephen Talley wrote:
> Ben Fritz wrote:
>
> > On Wednesday, June 5, 2013 12:31:43 PM UTC-5, Stephen Talley
> > wrote:
> > > I use sidescrolloff to make sure I can see several columns ahead
> > > of the cursor
> > >
> > > on long lines. However, even when a line is short enough to fit
> > > entirely on the
> > >
> > > screen, vim still scrolls even though there is no need to.
> > >
> > > Is there a way to turn off horizontal scrolling when a line
> > > doesn't need it?
> >
> > You could use a CursorMoved autocmd, that checks the line length,
> > and sets or clears the option in response. You may want to use
> > CursorMovedI as well.
>
> Thanks Ben. This seems like the best alternative baring a formal
> vim option to govern this behavior.
In case anyone else is interested, I used this to make sure that
horizontal scrolling never scrolls beyond the end of the line:
augroup AllFiles
autocmd!
" Amend &sidescrolloff based on cursor position
autocmd CursorMoved,CursorMovedI * call UpdateSideScroll()
autocmd END
let g:sidescrolloff = 15
function! UpdateSideScroll()
if &wrap == 0
let inInsert = mode() =~ "[iR]"
let offset = inInsert ? 2 : 1
let vend = virtcol("$")
let vcol = virtcol(".")
let &l:sidescrolloff = min([g:sidescrolloff, vend - vcol - offset])
" echo &l:sidescrolloff
if (!inInsert && vend - vcol < g:sidescrolloff)
normal ze
endif
endif
endfunction
Steve
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sunday, June 9, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment