Am 16.01.2013 19:16, schrieb Asis Hallab:> Dear Vimmers,
>
> I was just wondering, if it is possible to delete a range of lines
> without moving the cursor.
>
> Example:
> line one
> line two
> line three
> current line
>
> :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
Wednesday, January 16, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment