If this is your first time working in the command line environment, you may want to learn some basic Linux commands before you proceed with this article.
Using the Nano editor
Editing files with the Nano text editor is easy. To open a file in Nano, type the following command at the command line:If the specified file does not exist, Nano creates it.
Using the Vim editor
To open a file for editing in Vim, type the following command at the command line:If you are wondering why you type vi instead of vim , the vi command is a link to vim. One of the earliest text editors on Unix systems was the Vi editor. Vim (“Vi Improved”) is a Vi clone that has many more features than the original. You can type vim to start the Vim editor if you want, but vi is shorter and does the same thing.
i. Note that the status line at the bottom of the screen changes to —INSERT—. You can now make changes to the file. To navigate around the file while you are in insert mode, use the arrow keys and Page Up/Page Down keys.
To return to normal mode, press ESC. Note that the —INSERT— status line at the bottom of the screen goes blank. Now you can type commands to save your changes, search for text, and so on.
To write your changes without exiting Vim, type :w and then press ENTER. To exit Vim, type :q and then press ENTER. To write your changes and exit Vim at the same time, type :wq and then press ENTER.
More information
This article is a very basic introduction to using the Nano and Vim text editors. Both of these editors, and Vim in particular, have many more features and customizations available:- To view the online documentation for the Nano text editor, please visit http://www.nano-editor.org/docs.php.
- To view the online documentation for the Vim text editor, please visit http://www.vim.org/docs.php.