Skip to content

Instantly share code, notes, and snippets.

@Osse
Forked from mhinz/gist:7098910
Created October 22, 2013 12:10
Show Gist options
  • Save Osse/7099481 to your computer and use it in GitHub Desktop.
Save Osse/7099481 to your computer and use it in GitHub Desktop.
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 BOTH WAYS !!!!
let direction = 2 * (s:newline > s:oldline) - 1
while index(s:section_header_lines, s:newline) != -1
let s:newline += direction
endwhile
if empty(getline(s:newline)) | let s:newline += direction | endif
if index([0, s:lastline, headoff], s:newline) == -1 | let s:newline = [0, s:lastline, headoff][direction] | 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