Eric Leenman wrote:
[snip]
nmap <silent><PageDown> :exe "norm ".winheight(0)."j"<cr>
nmap <silent><PageUp>   :exe "norm ".winheight(0)."k"<cr>
nmap <silent><c-home> :let x=col('.')<bar>1<bar>exe "norm ".x."<bar>"<cr> nmap <silent><c-end> :let x=col('.')<bar>$<bar>exe "norm ".x."<bar>"<cr>
[snip]

This works great.

I'm trying to map them also to visaul-mode but then I get the error:
"no range allowed"
Why is that?

I have:

vmap <silent><c-s-PageDown> :exe "norm ".winheight(0)."j"<cr>
vmap <silent><c-s-PageUp>   :exe "norm ".winheight(0)."k"<cr>
vmap <silent><c-s-home> :let x=col('.')<bar>1<bar>exe "norm ".x."<bar>"<cr> vmap <silent><c-s-end> :let x=col('.')<bar>$<bar>exe "norm ".x."<bar>"<cr>

Rgds,
Eric

Hitting the : key in Visual mode causes the visual highlight to disappear, and Vim adds a "range" as :'<,'> which means "from the first to the last line of the latest Visual highlight".

In this case you will want to clear the range before the Ex-command (e.g. by means of <C-U>, see ":help c_CTRL-U"); but restoring the highlight after scrolling (with "gv" q.v.) will move the cursor back to one end of the visual area, possibly canceling the scroll...

You might prefer to set 'nostartofline' and then use <PageUp> and <PageDown>

Best regards,
Tony.

Reply via email to