Interesting!
So, I will have to write my own command for this.
I put this here in my .vimrc
" Delete range without moving cursor:
com! -range D <line1>,<line2>d | norm <C-o>
>> Example:
>> line one
>> line two
>> line three
>> current line
:1,2D
now does the trick.
Many thanks to everyone's feedback.
>>
>> :1,2d
>> Deletes the first two lines and leaves the cursor on line three.
>>
>> But I would like to leave it on the current position ('current line').
>>
>> Kind regards!
>
>
> Yep, looks like there is something "wrong" in Vim:
>
> :yank, :change, :append/:insert, :delete
> getline(), setline(), append(), ?delete()?
>
> There should be a function delete() to delete lines without moving the
> cursor, but the function of this name already deletes a file. And there
> is no other equivalent function.
>
> You can use
> :h winsaveview()
> :h winrestview()
> to save/restore the cursor position;
> or
> :let savpos = getpos(".")
> ...
> :call cursor(savpos[1:])
> " or :call setpos(".", savpos)
> or a mark ...
>
> --
> Andy
>
>
> --
> 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 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
Wednesday, January 16, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment