Table of Contents
Sometimes you do not have the possibility to edit or add files via a GUI.
To create or edit text files you need to use one of the many available terminal text editors. Some popular are:
- Vi and Vim
- EMACS
- Nano
In the following examples I will explain how the “Vim” editor works, since I am used to it.
Is VIM already installed?
The easiest way to check if vi or vim is installed is via one of the following commands:
“vim -v” or “vi -v“
If vim or vi is installed you should see something like that:
Create and edit files
Already present files can be edited via:
vim <Filename>
After that the given files opens in the VIM Editor.
In the current “mode” we can not add or edit text directly as you are used to.
Instead you have to change the “mode” into “Insert”-Mode.
The “Insert”-Mode can be activated via the letter “i”.
Now you can add and edit text via the “normal” way you are used to.
Saving and closing files
Now you probably would ask “How do I save the current file?”.
There is no bar at the top that says something like “File” => “Save” or something like that.
To execute commands inside VIM we have to get out of the “Insert”-Mode.
We can do that via the “ESC” key. After that the text “– INSERT –” at the bottom left of the terminal goes away.
Now we are in the “COMMAND”-Mode and therefore can execute commands
Command | Description |
:w | Write |
:q | Quit |
u | Undo |
y | Yank (Copy) |
p | Paste |
Therefore if we want to save and close the current file we have to input the following command:
:wq
These are the bare basics you need to use vim and therefore manage files in the terminal. A more in depth guide can be found here: https://www.howtoforge.com/vim-basics
Difference between Vi and Vim
“Vi” ca be installed on all POSIX systems, but this version just has the bare “essentiell” functionality built in.
“Vim” (= Vi IMproved) is an extended version of the “default” Vi editor which has built in functions.
Einige Beispiele dafür:
- Syntax highlighting
- Undo/Redo
- Split-Screen/Multifile editing
- Diff function to compare different files
- Many more plugins