summaryrefslogtreecommitdiffstats
path: root/vimrc
diff options
context:
space:
mode:
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc26
1 files changed, 10 insertions, 16 deletions
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 <silent>af <Esc>:call Textobj_fold(0, v:operator, v:prevcount)<CR>
-onoremap <silent>if <Esc>:call Textobj_fold(1, v:operator, v:prevcount)<CR>
-xnoremap <silent>af <Esc>:call Textobj_fold(0, 'v', v:prevcount)<CR>
-xnoremap <silent>if <Esc>:call Textobj_fold(1, 'v', v:prevcount)<CR>
+call Textobj('f', 'Textobj_fold')
" }}}
" }}}