Although you can edit text files in cPanel (if your account includes cPanel), it is often quicker and easier to do so from the command line. This article describes how to use the Nano and Vim editors to edit text files from the command line.
The Nano editor is probably easier for beginners to use initially. On the other hand, the Vim editor is in more widespread use, and has a long list of features. Try both editors, and use whichever one you feel more comfortable with.
Editing files with the Nano text editor is easy. To open a file in Nano, type the following command at the command line:
Replace filename with the name of the file that you want to edit.
To edit the file, just start typing your changes. To navigate around the file, you can use the arrow keys on your keyboard. If the file's contents are too long to fit on the screen, you can press Ctrl+V to move forward a page, and Ctrl+Y to move back a page.
When you are ready to save your changes, press Ctrl+O, verify the filename, and then press ENTER. To exit Nano, press Ctrl+X.
You can access Nano's online help at any time by pressing Ctrl-G.
To open a file for editing in Vim, type the following command at the command line:
Editing files with Vim is not as intuitive as with Nano. You can't just start typing your changes, because Vim starts in normal mode. In normal mode, anything you type on the keyboard is interpreted as a potential command, not changes to the text.
To make changes to the text, you must enter insert mode. To do this, type 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.
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:
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.