diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-29 16:28:21 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-29 16:28:21 -0500 |
commit | 06f286deb40c7f891386b0c68b7c1400c7c7f286 (patch) | |
tree | 8e92cf7a9520ac26257b4eb78ce335f552a6fdcf | |
parent | 40ebc166a3da6e46125356f85c03ab54d3307e03 (diff) | |
download | vim-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-- | vimrc | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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') +" }}} " }}} " }}} |