To clear the contents of a file is opening. Let's try folow the following command.
:1,$d
Other basic useful command :
* Create a file
vi filename
* To exit vi and save changes:
ZZ or :wq
* To exit vi without saving changes:
:q!
* To edit file content :
i
* Deleting Text :
:1,$d
Other basic useful command :
* Create a file
vi filename
* To exit vi and save changes:
ZZ or :wq
* To exit vi without saving changes:
:q!
* To edit file content :
i
* Deleting Text :
* | x | delete single character under cursor |
---|---|---|
Nx | delete N characters, starting with character under cursor | |
dw | delete the single word beginning with character under cursor | |
dNw | delete N words beginning with character under cursor; e.g., d5w deletes 5 words | |
D | delete the remainder of the line, starting with current cursor position | |
* | dd | delete entire current line |
Ndd or dNd | delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines |
* Searching Text:
/string | search forward for occurrence of string in text | |
---|---|---|
?string | search backward for occurrence of string in text | |
n | move to next occurrence of search string | |
N | move to next occurrence of search string in opposite direction | |
* Screen Manipulation:
^f | move forward one screen | |
---|---|---|
^b | move backward one screen | |
^d | move down (forward) one half screen | |
^u | move up (back) one half screen | |
^l | redraws the screen | |
^r | redraws the screen, removing deleted lines | |