aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-29 16:28:21 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-29 16:28:21 -0500
commit06f286deb40c7f891386b0c68b7c1400c7c7f286 (patch)
tree8e92cf7a9520ac26257b4eb78ce335f552a6fdcf
parent40ebc166a3da6e46125356f85c03ab54d3307e03 (diff)
downloadvim-textobj-06f286deb40c7f891386b0c68b7c1400c7c7f286.tar.gz
vim-textobj-06f286deb40c7f891386b0c68b7c1400c7c7f286.zip
beginnings of a text object for function arguments. it only handles single line functions at the moment
-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')
+" }}}
" }}}
" }}}