Close Menu
    Facebook X (Twitter) Instagram Pinterest YouTube
    Trending
    • Disable SSH Password Login on Raspberry Pi
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    Facebook X (Twitter) Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        February 16, 2024

        Disable SSH Password Login on Raspberry Pi

        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Software»Quick Guide To nano Text Editor On The Raspberry Pi
      Nano text editor on the Raspberry Pi

      Quick Guide To nano Text Editor On The Raspberry Pi

      6
      By Matt on November 14, 2013 Software, Tutorials & Help

      If I need to edit text files directly on my Raspberry Pi my text editor of choice is nano. There are other text editors available but I prefer nano’s relatively straightforward interface.

      As a command line based utility it may feel strange for users who are more familiar with a graphical interface but it is easy to learn the basics. Syntax colouring is available which makes reading and reviewing scripts easy.

      Launching nano

      To start nano you can simply type nano at the command prompt. This will launch with a “new buffer”. In other words an empty text file that has no name.

      In order to launch an existing text file you type nano followed by the file name :

      nano berryclip_01.py

      You will see something like this :

      nano Text Editor Screenshot #1
      nano Main Screen

      If your file is not in the current directory you will need to specify the full path :

      nano /home/pi/berrryclip/berryclip_01.py

      If the file is a system file you may need to use elevated permissions :

      sudo nano -w /etc/fstab

      Note: Always use the -w switch when opening system files. It disables wrapping long lines and ensures the file isn’t modified in a way that may affect your system.

      Editing Text

      Once in nano you can start typing. Additional functions can be activated by using the CTRL or ESC keys. These short-cuts are listed at the end of this post. You can list these keys while in nano using CTRL+G (Press and hold the CTRL key then press the G key) :

      nano Text Editor Screenshot #2
      nano Help Pages (CTRL+G)

      Return to the main screen using CTRL+X.

      To get you started here is a brief summary of nano’s most useful features.

      Saving and Quiting

      To save a file you can use CTRL+O.

      To quit nano you can use CTRL+X. You will be prompted to save your file if it has changed and you can answer this prompt with either a Y or a N. If you’ve changed your mind at this point you can return the main edit screen using CTRL+C.

      Cutting and Pasting

      Cut a line using CTRL+K. To copy a line use ALT+6.

      Paste a line at the cursor position using CTRL+U.

      To cut or copy multiple lines use CTRL+K or ALT+6 on each line and then paste them all using a single CTRL+U. They are pasted in the order that you cut/copied them. Using CTRL+U again will paste another set of text if required.

      You can also mark a block of text before cutting. Position your cursor at the start of the text and press CTRL+6. Then position your cursor after the text and use CTRL+K or ALT+6 to cut or copy. CTRL+U to paste.

      Searching and Replacing Text

      To search for text use CTRL+W. Enter the text you need to find and press Enter. To repeat the search use ALT+W.
      To perform a search and replace use ALT+R.

      You can’t open files once nano is running. Although you can insert a file into the current buffer you can not open a file directly once you are in nano. You need to launch it from the command line. I find this quite strange. If you need to edit a number of files you need to quit and then load each one in turn from the command line.

      Key Short-cut Summary

      For some reason the official nano website keeps the nano “Control” and “Meta” short-cuts a closely guarded secret so I have listed them here.

      ControlMetaDescription
      CTRL+GDisplay the help text
      CTRL+XClose the current file buffer / Exit from nano
      CTRL+OWrite the current file to disk
      CTRL+RInsert another file into the current one
      CTRL+WSearch for a string or a regular expression
      ALT+WRepeat last search
      CTRL+\\ALT+RReplace a string or a regular expression
      ControlMetaDescription
      CTRL+KCut the current line and store it in the cutbuffer
      ALT+6Copy the current line and store it in the cutbuffer
      CTRL+UPaste from the cutbuffer into the current line
      ALT+TCut from the cursor position to the end of the file
      ALT+AMark text at the cursor position
      CTRL+CDisplay the position of the cursor
      CTRL+_ALT+GGo to line and column number
      CTRL+TInvoke the spell checker, if available
      ALT+}Indent the current line
      ALT+{Unindent the current line
      ControlMetaDescription
      CTRL+YMove to the previous screen
      CTRL+VMove to the next screen
      CTRL+FMove forward one character
      CTRL+BMove back one character
      CTRL+SpaceMove forward one word
      ALT+SpaceMove back one word
      CTRL+PMove to the previous line
      CTRL+NMove to the next line
      CTRL+AMove to the beginning of the current line
      CTRL+EMove to the end of the current line
      ALT+( or ALT+9Move to the beginning of the current paragraph
      ALT+) or ALT+0Move to the end of the current paragraph
      ALT+\\ or ALT+|Move to the first line of the file
      ALT+/ or ALT+?Move to the last line of the file
      ALT+]Move to the matching bracket
      ALT+- or ALT+_Scroll up one line without scrolling the cursor
      ALT++ or ALT+=Scroll down one line without scrolling the cursor
      ALT+< or ALT+,Switch to the previous file buffer
      ALT+> or ALT+.Switch to the next file buffer
      ALT+VInsert the next keystroke verbatim
      CTRL+IInsert a tab at the cursor position
      CTRL+MInsert a newline at the cursor position
      CTRL+DDelete the character under the cursor
      CTRL+HDelete the character to the left of the cursor
      ControlMetaDescription
      CTRL+JJustify the current paragraph
      ALT+JJustify the entire file
      ALT+DCount the number of words, lines, and characters
      CTRL+LRefresh (redraw) the current screen
      ALT+XHelp mode enable/disable
      ALT+CConstant cursor position display enable/disable
      ALT+OUse of one more line for editing enable/disable
      ALT+SSmooth scrolling enable/disable
      ALT+PWhitespace display enable/disable
      ALT+YColor syntax highlighting enable/disable
      ALT+HSmart home key enable/disable
      ALT+IAuto indent enable/disable
      ALT+KCut to end enable/disable
      ALT+LLong line wrapping enable/disable
      ALT+QConversion of typed tabs to spaces enable/disable
      ALT+BBackup files enable/disable
      ALT+FMultiple file buffers enable/disable
      ALT+MMouse support enable/disable
      ALT+NNo conversion from DOS/Mac format enable/disable
      ALT+ZSuspension enable/disable

      Note : Some operations have multiple short-cuts.


      The official GNU nano editor homepage : https://www.nano-editor.org/

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleQuick And Dirty Experiments With Infrared Illumination
      Next Article DigiMakers Bristol – 16th November 2013

      Related Posts

      Disable SSH Password Login on Raspberry Pi

      How to Add a Raspberry Pi Pico Reset Button

      Pi Pico Onboard LED

      6 Comments

      1. Zak on November 15, 2013 4:29 pm

        vi

        Reply
      2. Derek Knight on November 15, 2013 8:45 pm

        Thanks for this. I’ve always found nano a bit too hard to get into, having used emacs many years ago, and I’m now used to emacs commands. That said, I have to recommend zile (zile is like emacs). A full emacs implementation is a bit big for a Pi, but I find zile to be just as good. Not wanting to start a religious war…

        Reply
      3. Bruno on November 16, 2013 2:05 am

        VI much better.

        Reply
        • xxx on December 1, 2013 8:00 pm

          and much more difficult

          Reply
      4. Jeffrey Herr on February 6, 2014 7:11 pm

        Seriously… This editor is a hog’s breath away from vi in terms of horrid usability curve. Alt-6, really????

        Reply
      5. Raspberry Pi on February 27, 2014 6:33 pm

        It is a very easy use text editor but it is easier just to use leafpad.

        Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Latest Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      Facebook X (Twitter) Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2024 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.