The Start


Hi, What and Why

Compare to Arduino

What do you need to buy ?

It's plugged in, what's first ?

How to install packages.

Recommended packages.

Essential Linux Commands.

How to use the vi editor.

The next step


Set up I2C.

My first program - blink.

VNC - Use your computer to control your Pi.

Samba - copy files.

How to use vi

If you can learn to use vi to edit files, you will find your linux life becomes much easier. GUI editors sometimes changes the format of the text you see on your screen when you write the file. vi highlights all characters in the file that aren't plain text.

Summary of vi

vi has two modes. Navigation mode and text entry mode.
When you start vi, you start in navigation mode.
To get to text entry mode, navigate to where you want to enter text, and press 'i'. Then type in the text you want to enter.
To return to navigation mode, press 'ESC'.

Navigation mode

To get to navigation mode, press ESC once or more times. You're now in navigation mode.
Use your arrow keys to move around the file. Once you're familiar with doing this, you can go to 'faster navigating' below.
If you have just started and you're editing a new file, then there's nothing to navigate - so press 'i' to go to text entry mode and start entering your text.

text entry mode

To get into text entry mode requires you to press one of these keys :
i - insert text where the cursor is
I - insert text at the start of the line
a - append text after the cursor
A - append text at the end of the line

Faster navigating

Once you're happy using the arrow keys to move around the file, these are faster ways to do the same thing.
w - move forward one word
b - move backward one word
1G - Go to line 1
50G - go to line 50
G - Go to the last line in the file
<ctrl>f - Go forwards one page
<ctrl>b - go backwards one page

Deleting text

In navigation mode;
x - delete the character at the cursor
dw - delete a word
dd - delete a line
5dd - delete 5 lines

Saving and quitting vi

In navigation mode; pressing : (colon) will make your cursor jump to the bottom of the screen, ready for write and/or quit commands.
:w - write the file (ie, save it to disk)
:q - quit vi (this will warn you if you try to quit without saving)
:q! - quit vi ignoring any unsaved changes
:wq - write the file to disk and quit
$
$ vi myfile
 

Using the vi commands above, practice entering text and saving your file. Yes, you can use <ctrl>v to paste text from the clipboard. You must be in text entry mode ! This is often the quickest way to copy text from a webpage into a file.

If you paste text when you are in navigation mode, then vi will take the characters as navigation keys. You can practice this also, to see what I mean.

If you get into trouble, press ESC to ensure you're in navigation mode, then press :q! to quit vi immediately and start again.