Using vi to edit a file in terminal [duplicate]
vi = too hard to use for a new user
nano = text editor that is run from the terminal like vi, only it's much easier to use for 2 reasons:
- The instructions for using nano editor are always found at the bottom of every page.
- The only two nano keyboard shortcuts that you need to know are for WriteOut and Exit. Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited. Press the keyboard combination Ctrl+X to exit nano.
nano is installed by default in Ubuntu.
Tip - Make the terminal easier to read. In the terminal select Edit -> Profile Preferences -> Colors tab and change the Background color to black and the Text color to white.
vi
or vim
is an advanced editor. So I will suggest you to get familiar with it before using it.
For now:
If you want to edit a file using terminal, press
i
to go intoinsert
mode.Edit your file and press ESC and then
:w
to save changes and:q
to quit.
However, you can combine these two like :wq
to write and quit the vim
editor.
If you want to learn how to use
vim
editor, use vimtutor
command, which starts the Vim tutor.
You can also use gksu gedit /etc/icinga/objects/localhost.cfg
to open it in gedit and work from there, if you are having trouble using vi
.
But G_P is right, type man vi
in the terminal and it should give you all the instructions.