From 510c3a6d6680603456beecbad892834ec2de4296 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Thu, 24 Apr 2008 22:43:23 -0500 Subject: add a / text object for regexes --- vimrc | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/vimrc b/vimrc index e830c79..03ddc2d 100644 --- a/vimrc +++ b/vimrc @@ -583,4 +583,57 @@ if file_readable(s:session_file) && expand("%:.") !~ '^/' endif " }}} " }}} +" Text objects {{{ +" / for regex {{{ +function Textobj_regex(inner, operator) + let pos = getpos('.') + let objstart = 0 + let objlength = 0 + + let line = strpart(getline('.'), 0, pos[2]) + let lines = getline(1, pos[1] - 1) + [line] + let linenum = pos[1] + for line in reverse(lines) + let objstart = match(line, '.*\zs\\\@a/ :call Textobj_regex(0, v:operator) +onoremap i/ :call Textobj_regex(1, v:operator) +xnoremap a/ :call Textobj_regex(0, 'v') +xnoremap i/ :call Textobj_regex(1, 'v') +" }}} +" }}} -- cgit v1.2.3