> On Tue, May 4, 2010 6:13 am, BC wrote:
>> I thought the question was how to swap the line above the current line
>> with the one below it, without changing the current line. I'd like to
>> know how to do that, without affecting the registers.
>
> Ok, this is cheating, since you are actually changing the current line:
> :call setline(line('.')-1, reverse(getline(line('.')-1, line('.')+1)))
>
> This will fail, if you are on the last or first line of a buffer.
or alternatively, you could even use a substitute command:
:.-,.+s/\v^(.*)\n(.*)\n(.*)/\3\r\2\r\1/|-
which selects the previous line, the current line and the following line
and swaps the first and the third and moves the cursor back to the
middle line.
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
No comments:
Post a Comment