135845Re: How to determine the start of a visual block (C-V) when it starts in the void?
- Jan 30, 2013On Wed, January 30, 2013 16:49, Axel Bender wrote:
> Hi Ben,For expression mappings, you don't need the trailing <CR>, because
> try this:
> xnoremap <silent> _C :<C-U>call SomeFunc()<CR> " My current
> xnoremap <silent><expr>_D SomeFunc()<CR> " John's proposal
they don't execute the rhs of the mapping, but rather evaluate it.
> xnoremap <silent> _E SomeFunc()<CR> " same w/o <expr>Not sure, what you are expecting here. This won't work.
>The problem is, expression-mappings are not allowed to change the
> fun! SomeFunc()
> let col = virtcol("'<") - 1
> let ecol = virtcol("'>")
> for l in range(line("'<"), line("'>"))
> call setline(l, strpart(getline(l), col, ecol - col))
> 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).
text, therefore they can't work exactly the same. To work around this
issue, they need to return what the user would type, which would then
be executed. E.g. for your usecase, use this function (there might
actually be better ways to achieve what you want, I haven't thought
xnoremap <silent> _C :<C-U>call SomeFunc()<CR> " My current mapping
xnoremap <silent><expr>_D SomeFunc1() " John's proposal
let col = virtcol("'<") - 1
let ecol = virtcol("'>")
let range= range(line("'<"), line("'>"))
let result=printf(": for l in %s|".
\ "call setline(l, strpart(getline(l), %d, %d))|".
\ "endfor", string(range), col, ecol-col)
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@....
For more options, visit https://groups.google.com/groups/opt_out.
- << Previous post in topic Next post in topic >>