In vim, how can I delete all lines in a file except the last 100 lines?

In normal mode: G100kdgg In other words: G -> go to last line 100k -> go up 100 lines dgg -> delete to top of file.

Simple and elegant. I like it! – technomalogical Aug 10 '09 at 17:51.

In ex mode: :1,$-100d Explanation: ":" puts the editor in "ex mode". The d command of ex mode deletes lines, specified as a single line number, or a range of lines. $ is the last line, and arithmetic can be applied to line numbers.

2 FWIW this is the better answer, IMHO – Nathan Fellman Aug 22 '09 at 8:15.

An alternative general purpose solution: :%! Tail -100 You can use any shell command after the! To arbitrarily modify the current buffer.

Vim starts the command and feeds the current file to stdin, and reads the new buffer from stdout.

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