VIM is a free text editor, open-source in Unix-like/Linux command line. The main purpose of an editor is to create, add, or modify text for a file.
vi [tùy_chọn] [filename]
Adding, Changing, and Deleting Text
Note: You cannot go back more than one step.
The following commands allow you to insert and add text. Each of these commands puts the vi editor into insert mode; thus, the
<Esc> key must be pressed to terminate the entry of text and to put the vi editor back into command mode.
|*||i||insert text before cursor, until <Esc> hit|
|I||insert text at beginning of current line, until <Esc> hit|
|*||a||append text after cursor, until <Esc> hit|
|A||append text to end of current line, until <Esc> hit|
|*||o||open and put text in a new line below current line, until <Esc> hit|
|*||O||open and put text in a new line above current line, until <Esc> hit|
Usually the new or modified file is saved when you leave vi. However, it is also possible to quit vi without saving the file.
Note: The cursor moves to bottom of screen whenever a colon (
:) is typed. This type of command is completed by hitting the
|*||:x||quit vi, writing out modified file to file named in original invocation|
|:wq||quit vi, writing out modified file to file named in original invocation|
|:q||quit (or exit) vi|
|*||:q!||quit vi even though latest changes have not been saved for this vi call|
|/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|