Tuesday, October 2, 2012

Re: Visual mode maps with and folds in vimscript

Hi Silas!

On Di, 02 Okt 2012, Silas Silva wrote:

> Hi again!
>
> I'm trying to remap '}' and '{' to a function with other paragraph
> definition. The map command is something like:
>
> nnoremap <silent> <buffer> } :call <SID>ParagraphNavigate()<CR>
> nnoremap <silent> <buffer> { :call <SID>ParagraphNavigate()<CR>
> vnoremap <expr> <buffer> } <SID>ParagraphNavigate()
> vnoremap <expr> <buffer> { <SID>ParagraphNavigate()
>
> In maps for Visual mode, I prefer to use <expr> because setpos() or
> :normal inside the function would exit Visual mode, so I work by
> returning normal commands (e.g. "20j") to build <expr>.
>
> The problem comes up when folds exist. Motion commands ("j", "k") don't
> open folds, they JUMP them, and "zO" exits Visual mode. setpos() points
> cursor correctly, but it exits Visual mode.
>
> I'd like to point the cursor correctly and open any fold that is
> opened, like traditional '}' and '{' do. Any tip on that?

I don't have a solution, but you could add gv to reselect the last
selected region.

regards,
Christian
--

--
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

No comments:

Post a Comment