" Jump to ':' starting the current block. Works ok with a numeric prefix
function! BlockBeg(mode) " go begin/back/up/out
let lNo = line('.')
let ref = indent(lNo)
while lNo > 0
let lNo -= 1
if indent(lNo) < ref
if len(getline(lNo)) > 0
execute lNo
if getline(lNo) =~ "[:=]$"
execute "normal! $"
else
execute "normal! $?[:=]\<CR>"
endif
return
endif
endif
endwhile
endfunction
" Jump to last char in last non-comment line of next indented block.
function! BlockEnd(mode)
let lNo = line('.')
let eof = line('$')
let ref = -1
let last = lNo
while lNo > 0 && lNo <= eof
if getline(lNo) =~ "^[ \t]*$" || getline(lNo) =~ "^[ \t]*#"
" echomsg "comment|blank line" lNo "XXX test comments/blanks @BOF/EOF
let lNo += 1
continue
endif
if ref == -1
let ref = indent(lNo)
" echomsg "refDent" ref
endif
let last = lNo
let lNo += 1
if indent(lNo) <= ref " outdent; Warp to last non-blank|cmt
execute last
execute "normal $"
return
endif
endwhile
endfunction
nnoremap <silent> =b :call BlockBeg("n")<CR>
nnoremap <silent> =e :call BlockEnd("n")<CR>