Editing Raspberry Pi Files

 

There are a number of text editors available for the Raspberry Pi and Linux.  Each editor has been designed for a specific purpose from general text editors and word processors to editors designed for programmers.  Emacs, vi,vim, nano and leaf pad are a few editors that each have their own unique methods of editing files.

Today you will learn the basics of Leafpad which is not as technical as Nano but has the advantage of being visual editor with basic document styling.  Nano is more complex and has a steeper learning curve but does have the advantage of being more flexible.

Open Leafpad by going to the Applications menu, select the Office menu and click on Leafpad.  Leafpad will open with a blank document.  Type a sentence into the document.  Adjust the font size by clicking on the Options menu, click the font item.  The window that appears will allow you to modify the font size and select different fonts as well as applying varying styles.

Select a font size of 22 and click OK.  The preview window previews the font size.  Save the document by selecting File –> Save as.  Enter the document name as suntimebox.txt and click Save.

Close down Leafpad and re-open it.  Open the document by selecting File–>Open and select the suntimebox.txt document.  The document will appear in the window.

To see a more complex editor at work, close down Leafpad.

Nano is a text editor that is invoked from a terminal window.  Nano is a quick tool for editing configuration files on your Raspberry Pi so it is found in most distributions or types of Linux based operating systems.  These types are also known as flavours.

Opening a terminal window by double clicking on the XTERM icon located on the desktop.

LX  Raspberry pi terminal

 

Enter the following and press enter.

sudo nano water.txt

This will start Nano with a file name called water.txt.   The menu system for Nano looks a little complex to start with but you will get the hang of it.  The symbol that is represented by the ^ symbol are menu options.  For example the ^X Exit means to exit. The commands can be invoked by holding down the control key (CTRL) and pressing the letter relating to the command.  The ^X in this instance means to hold down the control key and press the X.  This will cause the Nano text editor to exit.

Press CTRL^X to exit.

Start nano again but this time enter

sudo nano sand.txt

Enter a sentence into the editor and hold down the CTRL and press X.

A message will appear explaining that you are exiting Nano and that you should save any changes.

Press ‘y’ to save the file.

The second message asks you if you want to save the file name as sand.txt.  Press enter to save the file.  To confirm that you have created a file, enter the following into the terminal.

$cat sand.txt

You should see the sentence that you entered appear in the terminal window.

Now enter

sudo nano sand.txt

This will load the sand.txt file into nano  From here you can continue editing the file if you wish.

There are many editors to choose from when using a Raspberry Pi and nano is a great editor learn.  Leafpad is very basic but does allow you to style documents quickly.

Raspberry pi course week2-Day4 Networking

Next Raspberry Pi Week 2 – Day 4.0 >>