aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-05-07 06:06:30 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-05-07 06:06:30 -0500
commit0512f898c5ce10f2eef75e405440d721d4ed6807 (patch)
tree2d43ab7a2f7bd19f2830e6133e0abfc07caab694
parentc815ef6e32b925185339ddbd62a7205bb7a30287 (diff)
downloadvim-textobj-0512f898c5ce10f2eef75e405440d721d4ed6807.tar.gz
vim-textobj-0512f898c5ce10f2eef75e405440d721d4ed6807.zip
simplify the length calculation by quite a bit
-rw-r--r--vim/plugin/textobj.vim12
1 files changed, 4 insertions, 8 deletions
diff --git a/vim/plugin/textobj.vim b/vim/plugin/textobj.vim
index 0cda57a..85381df 100644
--- a/vim/plugin/textobj.vim
+++ b/vim/plugin/textobj.vim
@@ -15,15 +15,11 @@ function Textobj(char, callback)
if startline == endline
let objlength = endcol - startcol + 1
else
- let lines = getline(startline + 1, endline - 1)
- let lines = [strpart(getline(startline), startcol - 1)] +
- \ lines +
- \ [strpart(getline(endline), 0, endcol)]
let objlength = 0
- for line in lines
- let objlength += strlen(line) + 1
- endfor
- let objlength -= 1
+ if endline - startline > 1
+ exe 'let objlength += '.join(map(getline(startline + 1, endline - 1), 'strlen(v:val) + 1'), '+')
+ endif
+ let objlength += endcol + strlen(getline(startline)) - startcol + 2
endif
let whichwrap = &whichwrap
set whichwrap+=s