aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vimrc21
1 files changed, 21 insertions, 0 deletions
diff --git a/vimrc b/vimrc
index e9e10a4..a0e925b 100644
--- a/vimrc
+++ b/vimrc
@@ -378,6 +378,27 @@ function Textobj_fold(inner, count)
endfunction
call Textobj('f', 'Textobj_fold')
" }}}
+" , for function arguments {{{
+function Textobj_arg(inner, count)
+ let line = getline('.')
+ let curcol = col('.')
+ let argbegin = matchend(strpart(line, 0, curcol), '.*\%(,\s*\|(\)') + 1
+ let argend = match(strpart(line, curcol), '\zs.\?\%(,\|)\)') + curcol + 1
+
+ if a:inner == 0
+ if line[argend] == ')' && line[argbegin - 2] != '('
+ let argbegin -= 1
+ let argbegin = match(strpart(line, 0, argbegin), '\s*$')
+ elseif line[argend] != ')'
+ let argend += 1
+ let argend += matchend(strpart(line, argend), '^\s*')
+ endif
+ endif
+
+ return [line('.'), argbegin, line('.'), argend]
+endfunction
+call Textobj(',', 'Textobj_arg')
+" }}}
" }}}
" }}}