I am using Ubuntu and trying to delete all 100 lines from vi
editor but I got interview question of doing this in one command.
|
||||
add comment |
In normal mode, do |
|||||||||||||||||||||
|
etc. etc. |
|||||||||
|
If all lines in the file are to be deleted, this vi command specifies the range of deletion:
|
|||||||||
|
You want to delete all the lines in a file? Open the file with Just to note, the action If you know which consecutive lines to delete -- say, from line 101 to 200 -- type in the following key sequences: Esc:101,200d. |
||||
|
No matter where are you are in the file, you can do
Doing something like |
||||
|
echo -n > <file>
removes all lines from a file (actually just overwrites the file with ""). – Der Flatulator Aug 26 '13 at 9:41echo
at all for that;> $file
works just fine. – Michael Kjörling Aug 26 '13 at 13:01vi
in an interview? – Michael Kjörling Aug 26 '13 at 13:02vim-gtk
package, since that gives you access to the xclipboard within vim), typevimtutor
at the command line (not within vim) to get an interactive tutorial of the basics. It shouldn't take more than half an hour, and it's the best starter's guide to using vi/vim that you're likely to find. – evilsoup Aug 26 '13 at 14:03