67144Re: Functions with [range] do not preserve the cursor line
- Nov 19, 2012Am 19.11.2012 22:52, schrieb So8res:
> I think functions with [range] should preserve the cursor line. AssumeOne more hint: when you call that function from a mapping and you want a
> you have:
> function RangeTest() range
> echo line('.')
> 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
default range of `%', try the following:
cno <expr> <SID>% getcmdpos()==1 ? "%" : ""
" remove trailing ^M
no <script> <Leader>sm :<SID>%InFunc s/\r$//e<C-B>KeepView <C-E>
ou <Leader>sm|sunm <Leader>sm
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
- << Previous post in topic Next post in topic >>