aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-30 16:43:51 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-30 16:43:51 -0500
commitbc0761fde402c7b0edb16afe7ef6a559681cdf06 (patch)
treeacac9ca600616cb2196385541a945d8247603deb
parent594877882bfaf4db8b2af15f5254eda273db1ab7 (diff)
downloadvim-textobj-bc0761fde402c7b0edb16afe7ef6a559681cdf06.tar.gz
vim-textobj-bc0761fde402c7b0edb16afe7ef6a559681cdf06.zip
use recursion to make this cleaner, and use gE rather than <BS> if the character before a comma is a non-whitespace character
-rw-r--r--vimrc17
1 files changed, 9 insertions, 8 deletions
diff --git a/vimrc b/vimrc
index 092c92c..887ccc3 100644
--- a/vimrc
+++ b/vimrc
@@ -408,15 +408,16 @@ function Textobj_arg(inner, count)
let pos = getpos('.')
let curchar = getline(pos[1])[pos[2] - 1]
if curchar == ','
- exe "normal! \<BS>"
- let pos = getpos('.')
- let curchar = getline(pos[1])[pos[2] - 1]
- endif
- while curchar =~ '\s'
+ if getline(pos[1])[pos[2] - 2] =~ '\s'
+ normal! gE
+ else
+ exe "normal! \<BS>"
+ endif
+ return Textobj_arg(a:inner, a:count)
+ elseif curchar =~ '\s'
normal! W
- let pos = getpos('.')
- let curchar = getline(pos[1])[pos[2] - 1]
- endwhile
+ return Textobj_arg(a:inner, a:count)
+ endif
let line = strpart(getline(pos[1]), 0, pos[2])
let lines = getline(1, pos[1] - 1) + [line]