Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can delete in VIM all text from current line to end of file?

Tags:

file

text

vim

People also ask

How do I delete part of a line in Vim?

Deleting a single line in Vim editor: To delete a line, follow the steps below: First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.


dG will delete from the current line to the end of file

dCtrl+End will delete from the cursor to the end of the file

But if this file is as large as you say, you may be better off reading the first few lines with head rather than editing and saving the file.

head hugefile > firstlines

(If you are on Windows you can use the Win32 port of head)


Go to the first line from which you would like to delete, and press the keys dG


:.,$d

This will delete all content from current line to end of the file. This is very useful when you're dealing with test vector generation or stripping.


I use the following steps to do the same-

  1. Make sure you are in the normal mode by pressing Esc .
  2. Enter the Visual mode by pressing V .
  3. Press G i.e Shift + g to select the text from the cursor to the end of the file .
  4. Now press x to delete the selected text .