Created
October 22, 2013 11:20
-
-
Save mhinz/7098910 to your computer and use it in GitHub Desktop.
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:set_cursor() abort | |
let s:oldline = exists('s:newline') ? s:newline : 5 | |
let s:newline = line('.') | |
let headoff = s:headoff + 2 + s:secoff | |
" going down | |
if s:newline > s:oldline | |
while index(s:section_header_lines, s:newline) != -1 | |
let s:newline += 1 | |
endwhile | |
if empty(getline(s:newline)) | let s:newline += 1 | endif | |
if s:newline > s:lastline | let s:newline = s:lastline | endif | |
" going up | |
elseif s:newline < s:oldline | |
while index(s:section_header_lines, s:newline) != -1 | |
let s:newline -= 1 | |
endwhile | |
if empty(getline(s:newline)) | let s:newline -= 1 | endif | |
if s:newline < headoff | let s:newline = headoff | endif | |
endif | |
call cursor(s:newline, 5) | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment