From 06f286deb40c7f891386b0c68b7c1400c7c7f286 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Tue, 29 Apr 2008 16:28:21 -0500 Subject: beginnings of a text object for function arguments. it only handles single line functions at the moment --- vimrc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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') +" }}} " }}} " }}} -- cgit v1.2.3