Cut and paste in Vim without moving next line up?

It moves up because you have removed all the characters including line return/feed.

Up vote 3 down vote favorite share g+ share fb share tw.

When I cut and paste in VIM by pressing v, and go to the end of the line using $, and press d, the next line gets moved up to the same line I'm cutting. How do I stop this? Vim link|improve this question edited Sep 6 '11 at 10:13ib.7,62311121 asked Sep 6 '11 at 8:34user7016321266 58% accept rate.

Thanks guys for the help. – user701632 Sep 9 '11 at 4:14.

It moves up because you have removed all the characters including line return/feed. There are multiple solutions as usual with Vim. There is no "one true way" but you can try the following commands.

You can use D (capital) in normal mode which will erase everything until the end of line. See :help D Using another motion What you could do instead of using $ to move to the end of the line, use g_. It will move to the last non blank character of the line and won't select line return.

See :help g_ So vg_d should work as you want. Using Replace Alternatively, what you could do instead of cutting, you could replace the erased character by a blank using the space character. So v$rSPACE should work to erase but it will not save the replaced characters in register (for pasting later for example).

To cut everything from current cursor position until the end, use C. :he C will help you: Delete from the cursor position to the end of the line and count-1 more lines into register x, and start insert. Synonym for c$ (not |linewise|).

Doing so will cause the current line (assuming you are on the start of the line when hitting C) to become empty and the content is (by default) yanked into register " Edit: As Xavier notes in his comment (and his answer), the same could be achieved with D. It also cuts everything from current cursor position until the end of the line but doesn't go in insert mode after doing it.

I didn't know about C, but I am not sure that the OP want to replace the cut text. However, D exists and seems to work fine. – Xavier T.

Sep 6 '11 at 8:55 @Xavier: thanks for reminding me of D. Does almost the same except going to insert mode. Updated answer.

– eckes Sep 6 '11 at 9:01.

If you use these keystroke sequence then next line would not move up. V $ h d It is moving up because EOL character $ is also getting deleted without moving cursor 1 character back.

Just skip the visual mode and swap the other two commands, ie. Press d $. This is shorter than your starting one and doesn't break your tradition introducing other keystrokes you may not be familiar with.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions