I have written two functions two select inner and outer indent levels, which work perfectly.
However I tried to use vim scoping alà function scope#name
, which sadly doesn't seem to work in my case:
onoremap <silent> iz :<c-u>call <sid>sick#iz_motion(0)<cr>
onoremap <silent> az :<c-u>call <sid>sick#iz_motion(&tabstop)<cr>
vnoremap <silent> iz :<c-u>call <sid>sick#iz_motion(0)<cr>
vnoremap <silent> az :<c-u>call <sid>sick#iz_motion(&tabstop)<cr>
function s:sick#iz_motion(margin)
let l:cur_indent = indent(line("."))
while indent(line('.') - 1) >= l:cur_indent - a:margin
\ && getline(line('.') - 1) != ''
execute 'normal k'
endwhile
execute "normal V"
while indent(line('.') + 1) >= l:cur_indent - a:margin
\ && getline(line('.') + 1) != ''
execute 'normal j'
endwhile
endfunction