Delete n lines in the up direction in vim

Vim

Vim Problem Overview


Is there a command in vim which will delete n lines in the up direction.

I know I can use 4dd which will delete 4 lines downwards.

Vim Solutions


Solution 1 - Vim

In VIM, 3dk would delete 4 lines in the upward direction. Further documentation can be found at http://www.vim.org/docs.php

Solution 2 - Vim

V3kd would do it.

Thats "V" to enter visual line select mode, "3k" to move up 3 lines, and then "d" to delete the 4 lines you have selected.

Solution 3 - Vim

You can do it with a backwards range.

:-4,.d

Deletes from minus 4 lines to current. But this is an ex mode command.

Solution 4 - Vim

  1. Position the cursor where you want to begin cutting.
  2. Press v (or upper case V if you want to cut whole lines).
  3. Move the cursor to the end of what you want to cut.
  4. Press d.
  5. Move to where you would like to paste.
  6. Press P to paste before the cursor, or p to paste after.

http://vim.wikia.com/wiki/Copy,_cut_and_paste

Solution 5 - Vim

  1. stand at the end of the last line
  2. hold Backspace and wait until the last character of the first line is deleted

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser674669View Question on Stackoverflow
Solution 1 - VimchriskievitView Answer on Stackoverflow
Solution 2 - VimCharles KeepaxView Answer on Stackoverflow
Solution 3 - VimKeithView Answer on Stackoverflow
Solution 4 - VimMiMView Answer on Stackoverflow
Solution 5 - VimTrident D'GaoView Answer on Stackoverflow