Vim is a popular command line text editor available by default on most Unix/Linux Systems. If you do any SSH server admin, knowing the commands for one of these editors (or those like it) is essential. Otherwise it is a bit of a nightmare.
I would totally suggest doing this first. Just type
vimtutor in the terminal (on a Mac anyway). It is a great introduction AND it is built into the console!
Totes before doing anything, create a
.vimrc file. In there you can add any settings you want. First, start by setting the colour scheme.
and then type
i to change mode to 'insert' and then type:
esc (escape) to get out of insert mode, then type
:wq to save the document.
Running the Editor
Navigate to a file and type:
This will open the file in the editor. If the file doesn't exist Vim will create it.
Sometimes the colours are pants, so to see what colours are available run ('vimflavour' is whatever version of vim it is e.g. 'vim72'):
ls -la /usr/share/vim/[vimflavour]/colors
Then, for the 'desert' colours, in vim type:
:q! # Quit WITHOUT saving changes [shift]zz # Save file and exit :wq # Write file and exit
Move cursor to beginning of line
To move to the end of the line
h # Move the cursor to the left j # Move the cursor to the up k # Move the cursor to the down l # Move the cursor to the right
You can also prepend the above with a number in order to move around.
8h #moves the cursor 8 letters to the left 8j #moves the cursor 8 lines upwards 8k #moves the cursor 8 lines downwards 8l #moves the cursor 8 letters to the right
:45 #Move to line 45
When you have finished an insert,
Escape returns you to the editor.
cc will delete the line but maintain the space and automatically go into edit mode at the line you deleted (for quick overwrites).
u will undo your previous action.
To copy a line press
y and then
p to paste.
x # delete current character dd # delete current line
dd a line, it is saved in a buffer so if you press
p it will paste it.
/string # Finds next instance of string / # Finds next instance of predefined String
Great contributions from Latn Black