On Jun 9, 10:09 pm, Christian Brabandt <[email protected]> wrote:
> Hi Bee!
>
> On Do, 09 Jun 2011, Bee wrote:
>
>
>
> > I would like to jump to the next (or prev) line, always a multiple of
> > "tline".
>
> > let tline = 16
>
> > This calculates how many more lines to jump
> > useful with "j"
>
> > :echo tline - line(".") % tline
>
> > This calculates the line to jump to
> > useful with "G"
>
> > :echo ( line(".") / tline + 1 ) * tline
>
> > How to create a mapping?
>
> > This does NOT work.
>
> > :nmap J execute "normal " . tline - line('.') % tline . "j"
>
> You want an expression mapping:
>
> :nmap <expr> J tline-line('.')%tline.'j'
>
> See also the help at :h map-expression
>
> regards,
> Christian
> --

Thank you, Christian

Works great but for the offset I needed to add 1:

:nmap <expr> J tline+1-line('.')%tline.'jzt'
:nmap <expr> K tline+1-line('.')%tline.'kzt'

And now I also have the reverse.

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

Reply via email to