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.

vim ~/.vimrc  

and then type i to change mode to 'insert' and then type:

:color delek

press esc (escape) to get out of insert mode, then type :wq to save the document.

Running the Editor

Navigate to a file and type:

vim filename  

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:

:color desert

Quit Commands

:q!        # Quit WITHOUT saving changes
[shift]zz  # Save file and exit
:wq        # Write file and exit

Moving around

Cursor Commands

Move cursor to beginning of line 0

To move to the end of the line $


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  

Line numbers

:45            #Move to line 45

Edit Commands

When you have finished an insert, Escape returns you to the editor.

A 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.

Delete Commands

vim ~/.vimrc  

If you dd a line, it is saved in a buffer so if you press p it will paste it.

Search Commands

/string      # Finds next instance of string
/            # Finds next instance of predefined String


Great contributions from Latn Black