Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " author: godlygeek
- function s:movement_string(line, col)
- return a:line . "G0" . (a:col > 1 ? (a:col - 1) . "l" : "")
- endfunction
- function! s:VAR()
- let group = synID(line('.'), col('.'), 1)
- let orig = [ line('.'), col('.') ]
- let last = orig
- while (col('.') != 1 || line('.') != 1)
- \ && index(synstack(line('.'), col('.')), group) >= 0
- let last = [ line('.'), col('.') ]
- call search('.', 'bW')
- endwhile
- let beg = last
- call cursor(orig)
- let last = orig
- while (col('.') != col('$') || line('.') != line('$'))
- \ && index(synstack(line('.'), col('.')), group) >= 0
- let last = [ line('.'), col('.') ]
- call search('.', 'W')
- endwhile
- let end = last
- let g:rv = s:movement_string(beg[0], beg[1]) . "o" . s:movement_string(end[0], end[1])
- return g:rv
- endfunction
- vnoremap <expr> ar <SID>VAR()
- onoremap ar :normal var<CR>
Advertisement
Add Comment
Please, Sign In to add comment