aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-23 02:18:06 -0500
committerdoy <doy@tozt.net>2008-12-23 02:18:06 -0500
commit30c15e82111d2297bd6b14ed5c8481d030dc52c7 (patch)
treee7985b9651c6ed1f48f7ce7d95e4e3e7bb91f190
parenta00e88a61907b35c0bb4cfe9ff0a887806074d3e (diff)
downloadvim-textobj-30c15e82111d2297bd6b14ed5c8481d030dc52c7.tar.gz
vim-textobj-30c15e82111d2297bd6b14ed5c8481d030dc52c7.zip
convert regex textobj to allow arbitrary paired characters
-rw-r--r--vim/plugin/textobj.vim14
1 files changed, 7 insertions, 7 deletions
diff --git a/vim/plugin/textobj.vim b/vim/plugin/textobj.vim
index a603443..1a3769f 100644
--- a/vim/plugin/textobj.vim
+++ b/vim/plugin/textobj.vim
@@ -57,15 +57,15 @@ function Textobj(char, callback, ...)
endfunction
" }}}
" Text object definitions {{{
-" / for regex {{{
-function s:textobj_regex(inner, count)
+" arbitrary paired symbols (/ for regex, etc) {{{
+function Textobj_paired(inner, count, char)
let pos = getpos('.')
let line = strpart(getline(pos[1]), 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\\\@<!/') + 1
+ let objstart = match(line, '.*\zs\\\@<!'.a:char) + 1
if objstart != 0
break
endif
@@ -81,21 +81,21 @@ function s:textobj_regex(inner, count)
let lines = [line] + getline(pos[1] + 1, line('$'))
let linenum = pos[1]
for line in lines
- let objend = match(line, '\\\@<!/') + 1
+ let objend = match(line, '\\\@<!'.a:char) + 1
if objend != 0
if linenum == pos[1]
" have to account for the possibility of a split escape
" sequence
if objend == 1
if getline(pos[1])[pos[2] - 2] == '\'
- let objend = match(line, '\\\@<!/', 1) + 1
+ let objend = match(line, '\\\@<!'.a:char, 1) + 1
if objend == 0
let linenum += 1
continue
endif
else
- " if we're sitting on a /, don't do anything, since it's
- " impossible to know which direction to look
+ " if we're sitting on a char, don't do anything, since
+ " it's impossible to know which direction to look
throw 'no-match'
endif
endif