Difference between revisions of "Text Editors"
(→Nano) |
(→Geany) |
||
Line 17: | Line 17: | ||
Geany is a GUI based text editor for Linux. It is very similar to Notepad++ on Windows and supports essentially the same features. The programming language can be set for syntax highlighting. Take note of whether you are using tabs or spaces (4 spaces is recommended for indentation). This can be set through preferences - editor - indentation - type - spaces. After changing the setting, close and reopen the file. | Geany is a GUI based text editor for Linux. It is very similar to Notepad++ on Windows and supports essentially the same features. The programming language can be set for syntax highlighting. Take note of whether you are using tabs or spaces (4 spaces is recommended for indentation). This can be set through preferences - editor - indentation - type - spaces. After changing the setting, close and reopen the file. | ||
− | [[File: | + | [[File:Geany.png|thumb|The Geany Text Editor]] |
= Terminal Based Text Editors = | = Terminal Based Text Editors = |
Revision as of 10:41, 6 February 2020
Contents
Text Editors
When editing files on the Raspberry Pi there are multiple options, depending on whether you choose to edit the file in a specific program, or edit it within the command shell.
GUI Based Text Editors
Notepad++
Notepad++ is a text editor for Windows. It can be downloaded here. Language can be set to enable syntax highlighting. To ensure you use spaces instead of tabs, go to Settings - Preferences - Tab Settings - tick the box “Replace by Space”..
Geany
Geany is a GUI based text editor for Linux. It is very similar to Notepad++ on Windows and supports essentially the same features. The programming language can be set for syntax highlighting. Take note of whether you are using tabs or spaces (4 spaces is recommended for indentation). This can be set through preferences - editor - indentation - type - spaces. After changing the setting, close and reopen the file.
Terminal Based Text Editors
Nano
Nano is a very easy to use file editor that runs within the command shell. Nano comes installed on Ubuntu and Raspbian by default, but if you do find yourself needing to install it, you can run
$ sudo apt-get install nano
Once it is installed, you can use nano to edit text files by typing
$ nano filename
You will be presented with an interface like this (currently the user is editing the python template):
Commands for nano are displayed on the bottom. A quick reference is as follows:
- Arrow Keys to move around as expected
- Ctrl-W to find (Where is)
- Ctrl-O to save (Write Out)
- Ctrl-X to Exit (will be prompted to save on exit, press ’y’ to save, press ’n’ to exit without saving)
- On Windows using Putty SSH client, ’paste’ is performed by right-clicking with the mouse anywhere in the window, the contents of the clipboard will be pasted at the current cursor location
Note: By default, nano inserts a tab when the tab key is pressed. If you’d like to change this to insert a number of spaces, for example, four (as is recommended by PEP 8), do the following:
Edit your /.nanorc file (or create it)
$ sudo nano ~/.nanorc
Edit it to contain the following:
set tabsize 4 set tabstospaces
Reboot your Pi to enable the changes
Other Terminal Editors
There are other terminal based text editors, such as emacs and vim. Feel free to use whichever you are comfortable with.