Created
May 20, 2015 00:00
-
-
Save EvergreenTheTree/b81d035ff3483d5ee339 to your computer and use it in GitHub Desktop.
Vim fixed side scrolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:FixScroll() | |
if &wrap | |
return 0 | |
elseif col(".") - wincol() - &fdc + &number * &numberwidth ==# 0 | |
return 0 | |
endif | |
let l:targetcol = winwidth(0) - &sidescrolloff | |
if wincol() < l:targetcol | |
let l:move_amount = l:targetcol - wincol() | |
exe 'normal! ' . l:move_amount . 'zh' | |
endif | |
endfunction | |
" Run fixscroll command on cursor move | |
autocmd CursorMoved,CursorMovedI * call <SID>FixScroll() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment