Tuesday, April 16, 2013

Re: Determine the position we left off before moving to the command line

On Tue, April 16, 2013 08:42, Axel Bender wrote:
> Anyway. I attached a VimL file which shows the problem (at least here:
> version 7.3.903, Windows 7, 64 bit). Please try to execute :Hi w/o a
> visual block, the cursor being in line 2.
>

That is because of the way, function-range is implemented.

,----[ :h :call ]-
| :[range]cal[l] {name}([arguments])
| [匽
| Without a range and for functions that accept a range, the
| function is called once. When a range is given the cursor is
| positioned at the start of the first line before executing the
| function.
`----

Therefore I usually specify the firstline and lastline as parameter to
the function (with range attribute) and just call the function using
:call (without an address). This works around moving the cursor and
executes the function just once. Within the function, I can work
within the expected range.

I think, this was sometimes also discussed on vim_dev but changing
this behaviour would be a backwards incompatible change.

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

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