From 246b0a52a55eac622826464d35f4f6a45074363d Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Mon, 28 Apr 2008 01:25:40 -0500 Subject: convert the fold text object to use the new helper function --- vimrc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 771240a..4feb0bd 100644 --- a/vimrc +++ b/vimrc @@ -697,24 +697,18 @@ endfunction call Textobj('/', 'Textobj_regex') " }}} " f for folds {{{ -function Textobj_fold(inner, operator, count) +function Textobj_fold(inner, count) + let pos = getpos('.') + exe 'normal! '.a:count.'[z' - let startpos = line('.') + a:inner + let startline = line('.') + a:inner normal! ]z - let endpos = line('.') - a:inner - exe 'normal! '.startpos.'G' - exe 'normal! '.a:operator.endpos.'G' - - if a:operator == 'c' - normal! l - startinsert - elseif a:operator == 'v' - normal! $ - endif + let endline = line('.') - a:inner + + call setpos('.', pos) + + return [startline, 1, endline, strlen(getline(endline))] endfunction -onoremap af :call Textobj_fold(0, v:operator, v:prevcount) -onoremap if :call Textobj_fold(1, v:operator, v:prevcount) -xnoremap af :call Textobj_fold(0, 'v', v:prevcount) -xnoremap if :call Textobj_fold(1, 'v', v:prevcount) +call Textobj('f', 'Textobj_fold') " }}} " }}} -- cgit v1.2.3-54-g00ecf