Editing text at the command line with micro
Small and Simple
Editing text at the command line doesn't have to be daunting. Micro brings the ease and intuitiveness of a graphical editor to the Linux terminal.
Linux users are spoiled for choice when it comes to many types of software. That's especially true for text editors. When I first started writing this article, I tried to count as many editors as I could just off the top of my head. I stopped when I got to around 32.
Quite a few of those editors run at the command line. While I've used several, I've never had great relationships with command-line text editors. I'm not sure why that is. Maybe it's just we don't have enough in common with each other to form a strong bond. Recently, though, I was working with a command-line application that played better with terminal text editors than with graphical ones. So, I duly set my default editor to the venerable GNU nano editor, which was the only terminal editor installed on my computer. While I've used nano in the past, I was quickly reminded that it isn't for me.
Instead of using software I don't particularly like, I searched around for an alternative and came across micro [1]. Billed as "a modern and intuitive terminal-based text editor," micro turned out to be great substitute for nano. In this article, I look at how any Linux user, regardless of their level of comfort with the command line, can start using micro and configure it to meet their needs.
Setting Up
There are several ways you can install micro. The easiest of those is to install it using your Linux distribution's package manager. If micro isn't available in your package manager, run this command in a terminal window to download a prebuilt binary:
curl https://getmic.ro | bash
From there, move the file (conveniently named micro
) to a folder in your path.
Another option is to install micro as a snap package by running this command in the terminal:
snap install micro --classic
If compiling software is your thing, you can download micro's source code from its repository on GitHub [2]. The editor is written in the Go programming language. You'll need Go v1.11 installed on your computer, and you must enable Go modules as well.
Start a New File
So micro is on your computer. Now what? Get going by opening a terminal window and typing micro
or micro <name of file to edit>
. Figure 1 shows micro editing a new, empty file.
From there, start typing – nothing complex or out of the ordinary for any text editor, whether on the desktop or at the command line.
Micro uses many (if not all) of the same keyboard shortcuts that you're familiar with from using desktop applications – although the notation in the help section may differ slightly. For example, if you're used to seeing Ctrl+X, note that Ctrl-x is just another way to write the same key combination.
Copy text by highlighting it and pressing Ctrl+C. Paste that text by pressing Ctrl+V. Or press Ctrl+O to open a file and Ctrl+S to save it.
Press Ctrl+E and then type help defaultkeys
to display a list of micro's keyboard shortcuts.
You can also use your mouse to select and highlight text. There's no right-click support (as you'd find in a desktop application), but pressing the scroll wheel on your mouse pastes whatever is in your clipboard into your file.
Using the Command Bar
I've already mentioned the Ctrl+E shortcut. When you press that combination of keys, the editor's command bar displays at the bottom of the screen. In the command bar, you can type commands like replaceall
to find and replace all instances of a word or phrase, set softwrap true
to turn on word wrapping, or help commands
to get a list of all of micro's commands.
If you only remember part of the name of a command, type it and press the Tab key to complete it. If there are two or more possible completions, micro displays them and you can press the Tab key again to choose one (Figure 2).
For example, when you press Ctrl+O to open a file, you type the name of the file and, if it's in another directory, the path to that file on the command bar. Press the Tab key to complete the names of the directory and of the file.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.