function RangeTest() range
echo line('.')
endfunction
And you put the cursor on line 2 and :%call RangeTest()
This function will echo 1, because the cursor is moved to the beginning of the range *before* entering the function.
I was attempting to create a function which does a search-replace (:s) without moving the cursor (using winsaveview() and winrestview()). It turns out this is not possible, because the cursor is moved before winsaveview() can be called.
Is this the intended behavior, or is it a bug? If it's intended, is there a way to save the winview before entering a function with [range]?
--
You received this message from the "vim_dev" 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 from the "vim_dev" 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
Bump. Should I add tests? What's the process for adding tests? (I couldn't find a test testing function [range] and didn't think that adding a new test file was the right decision.
Are there any objections to adding this functionality?
Bram, do you have any preference on the name of this argument?
How do you feel about using 'range!' (with a bang) instead?
It would keep the :function argument space more concise, and would only be usable with 'range', both of which are nice. However, there's no precedent (that I can find) for command arguments having bangs.
Any word on getting a variant of range functions that don't move the cursorline? This still bites me occasionally.