aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-25 01:35:11 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-25 01:35:11 -0500
commita5d22cad51c1ca01ad433d8c7c69fead0cfe3ed9 (patch)
tree5d7c3180c8b5099126e0590a4031dd68d1a8a543
parent6056155c2f6e310dec5b8dc5fa094ab5e9f57b9e (diff)
downloadvim-textobj-a5d22cad51c1ca01ad433d8c7c69fead0cfe3ed9.tar.gz
vim-textobj-a5d22cad51c1ca01ad433d8c7c69fead0cfe3ed9.zip
hmmm, how about a fold textobj that actually works
-rw-r--r--vimrc20
1 files changed, 11 insertions, 9 deletions
diff --git a/vimrc b/vimrc
index 3dc30af..069caab 100644
--- a/vimrc
+++ b/vimrc
@@ -334,16 +334,18 @@ xnoremap <silent>i/ <Esc>:<C-U>call Textobj_regex(1, 'v')<CR>
" }}}
" f for folds {{{
function Textobj_fold(inner, operator, count)
- if a:inner == 1
- let pos = getpos('.')
- exe 'normal! '.a:count.'[zyyp'
- call setpos('.', pos)
- endif
-
- exe 'normal! '.a:count.']z'.a:operator.'[z'
+ exe 'normal! '.a:count.'[z'
+ let startpos = line('.') + a:inner
+ normal! ]z
+ let endpos = line('.') - a:inner
+ exe 'normal! '.startpos.'G'
+ exe 'normal! '.a:operator.endpos.'G'
- if a:inner == 0
- normal! dd
+ if a:operator == 'c'
+ normal! l
+ startinsert
+ elseif a:operator == 'v'
+ normal! $
endif
endfunction
onoremap <silent>af <Esc>:<C-U>call Textobj_fold(0, v:operator, v:prevcount)<CR>