Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you delete all text above a certain line

Tags:

vim

How do you delete all text above a certain line. For deletion below a line I use "d shift g"

like image 731
user339108 Avatar asked Oct 22 '22 09:10

user339108


People also ask

How do I delete all lines above vi?

Delete All Lines Press the Esc key to go to normal mode. Type %d and hit Enter to delete all the lines.

How do you delete entire lines?

If you're at the end of a line and want to select the complete line, use the shortcut key combination Shift + Home . If there's only one line of text in the document, or you want to delete all text, press Ctrl + A key to select all text. Once highlighted, press delete to delete everything.


1 Answers

dgg

will delete everything from your current line to the top of the file.

d is the deletion command, and gg is a movement command that says go to the top of the file, so when used together, it means delete from my current position to the top of the file.

Also

dG

will delete all lines at or below the current one

like image 576
Andy White Avatar answered Oct 23 '22 23:10

Andy White