Skip to content
Browse files

Proper plugin file

  • Loading branch information...
1 parent cd3cbde commit d9baa5ca3492ecc634f29e0649b6b05ae91165e6 @chreekat committed Dec 23, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 plugin/paren_crosshairs.vim
View
35 plugin/paren_crosshairs.vim
@@ -0,0 +1,35 @@
+func! s:targetMatchpairs()
+ if !exists('b:targetAcquired')
+ let b:targetAcquired = 0
+ endif
+ if !exists('b:matchPairs')
+ " '[:],{,},(,)' --> '[]{}()'
+ let b:matchPairs = substitute(&matchpairs, "[,:]", "", "g")
+ endif
+
+ let curChar = getline('.')[col('.') - 1]
+ let targetInReticule = len(curChar) > 0 && stridx(b:matchPairs, curChar) >= 0
+
+ if targetInReticule && !b:targetAcquired
+ let b:disengage = "set " . (&cuc ? "cuc" : "nocuc")
+ \. ' ' . (&cul ? "cul" : "nocul")
+ set cuc cul
+ let b:targetAcquired = 1
+ elseif !targetInReticule && b:targetAcquired
+ exec b:disengage
+ let b:targetAcquired = 0
+ endif
+endfu
+
+func! s:suspendTargeting()
+ if b:targetAcquired
+ exec b:disengage
+ let b:targetAcquired = 0
+ endif
+endfu
+
+augroup TargetMatchpairs
+ au!
+ au WinEnter,CursorMoved,CursorMovedI * call s:targetMatchpairs()
+ au WinLeave * call s:suspendTargeting()
+augroup END

0 comments on commit d9baa5c

Please sign in to comment.
Something went wrong with that request. Please try again.