Unless you’ve been a long time *nix user, you may not be part of the EMacx, vs vi school. Perhaps like me, you prefer using something like Nano to edit text files in the terminal.
Problem is, on many systems such as those running embedded Linux and using something like Busybox, these more user friendly editors simply aren’t available. Even if the system has a package manager and their exists your favourite editor in a package repositry, you may not have the permissions to install them. But you still need to edit a text file. Granted, if you’re not root or listed in sudoers, you’re not going to be able to edit anything in /etc anyway but maybe you just need to write a note in /home.
Thankfully the text editor vi should always be included in a Posix compatible environment, like those running Busy Box. But you load it up and realise you can’t use your mouse and you don’t have time to read the manual. Fear not, see below.
Vi operates in 2 modes. Command and insert. Insert is where you actually enter text, command operate upon the text.
Press i to enter insert mode and esc to back out to command mode.
If you’re not sure you’re in command or insert mode. Press escape a couple of times. You may hear a ping indicating you’re already in command mode.
These days cursor keys should work moving around in command mode, otherwise:
Left: UP: Down: Right:
h. j. k. l.
Enter insert mode
Some comomn commands: (Note caps.)
Exit with out save, ignore write protect.
Save / write
Save and overwrite protection.
Save and exit
:x. Or, :wq. Or ZZ
Save buffered file as:
Return to point of last save.
Edit another file with out leaving vi:
Some editting commands.
Give a number after command if desired.
Delete from cursor to end of word:
Delete from cursor to end of line.
Delete from current line to end of file.
Delete character under cursor:
Yank (copy) word from cursor
Yank (copy) line.
Paste after cursor.
Paste before cursor.
There are many more of course. Have a look at: