CHAPTER 3 - NANO EDITOR FOR LINUX



AD

Introduction to Nano text editor

We are ready to code our machine learning program. In Chapter 3 we will have a short discussion of how to use the Nano text editor. If you are comfortable using a text editor, skip to Chapter 4 to run a basic neural network program with the Pima Indians Database.

3.1 Introduction Nano is a widely used simple text editor in Linux. It is the default editor for Linux Ubuntu cron files. I learned on a Vi editor, which is not user friendly, but very versatile. I use a Pycharm editor for Python. I use a Visual Code Editor for webpages. The neural network program worked on a basic Nano editor. The program was copy and pasted from the webpage directly into the Nano editor, and run as a python file in an anaconda environment.

3.2. Installing nano editor on Debian/Ubuntu/Mint Linux

3.2.1 Open the terminal with Ctrl + Alt + t

3.2.2 Update the database of programs with the command:

sudo apt update

3.2.3 Install Nano with:

sudo apt install nano

3.3 Create or open and save a file with Nano

3.3.1 Create a new file called test.txt

nano test.txt

3.3.2 Type some text in the file


Logo

3.3.3 It takes the next three steps to exit the file and save your work from Nano.

3.3.4 Press Ctrl + x and you will get the following screen.



Logo

3.3.5 Press y and you will get the following screen.



Logo

3.3.6 Press Enter and you will exit Nano with your work saved.



Logo

3.3.7 Occasionally you will forget to type sudo in front of a nano command that requires root to modify it. You will get the error message Error writing: Permission denied, when trying to save your work. The fix is simple. Press Ctrl + x. Press n. This saves your file without modifications. You will have to open the file again with sudo nano filename, and make the changes again.

3.4 Keyboard combinations

3.4.1 There are keyboard combinations listed at the bottom of the nano screen. The Ctrl button is represented by the carat (^), and the Alt button is represented by the letter (M).

3.4.2 A short list of keyboard combinations
Ctrl + g is Help
Ctrl + x is Exit the file. You will be prompted to save your work.
Ctrl + o is Write Out or Save
Ctrl + w is Where is
Ctrl + j is Justify
Alt + u is Undo
Alt + e is Redo

3.5 Copy and Paste

3.5.1 I often copy and paste from web pages on the internet directly to Nano using a mouse.

3.5.2 You can copy and paste using the mouse in the Nano editor itself. Select the text to be copied with the mouse. Navigate cursor with arrow keys to the space you want to paste to. Use mouse to paste. Click with mouse to undo highlighting.

3.6 Search for a word

3.6.1 Press Ctrl + w . You will be prompted for the word you are looking for. Type it in and press Enter. The word will be located.

3.6.2 Press Alt + w to continue to the next location of the word.

3.7 Beginning of file and End of file

3.7.1 Go to the beginning of the file Alt + \

3.7.2 Go to the end of the file Alt + /

3.8 Move up or down one screenful

3.8.1 Move forward one screenful Ctrl + v

3.8.2 Move backward one screenful Ctrl + y







theSurfDragon.com


Conda Navigation

Table of Contents
Ch1-Installation
Ch2-Conda Navigator
Ch3-Nano Editor
Ch4-Run a Program
Ch5-Program Explained