Wednesday, January 30, 2013

Re: How to determine the start of a visual block (C-V) when it starts in the void?

Hi Ben,

try this:

xnoremap <silent> _C :<C-U>call SomeFunc()<CR> " My current mapping
xnoremap <silent><expr>_D SomeFunc()<CR> " John's proposal
xnoremap <silent> _E SomeFunc()<CR> " same w/o <expr>

fun! SomeFunc()
let col = virtcol("'<") - 1
let ecol = virtcol("'>")

for l in range(line("'<"), line("'>"))
call setline(l, strpart(getline(l), col, ecol - col))
endfor
endf

Select (ve=block) a visual block from "Fun" down to "ol ", the press _C, _D, and _E. Repeat the same (_C, _E) with an extended block (one line further down - in the void).

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment