Logo

dev-resources.site

for different kinds of informations.

Guide to using โ€˜edโ€™ editor in Linux

Published at
1/22/2024
Categories
ed
linux
editor
ubuntu
Author
pramod74
Categories
4 categories in total
ed
open
linux
open
editor
open
ubuntu
open
Author
8 person written this
pramod74
open
Guide to using โ€˜edโ€™ editor in Linux

โ€˜edโ€™ is a simple, straight-forward text editor available by default in Linux. It can be used to create / edit text files easily. If you ever get stuck in a situation where you donโ€™t have access to advanced editors like โ€˜viโ€™ (e.g., when trying to recover your system after a crash), or simply for fun, your knowledge of โ€˜edโ€™ can help you.

Letโ€™s go through a few basic commands for โ€˜edโ€™.

1. Invoking โ€˜edโ€™:

From the command line, invoke โ€˜edโ€™ by using the command โ€˜edโ€™ with (or without specifying) a file name. If a file name is specified, โ€˜edโ€™ loads the file contents in buffer, and outputs the number of characters in the file. If no filename is specified, no output is displayed. You can infer that โ€˜edโ€™ has been launched by noticing that the shell prompt (โ€˜$โ€™or โ€˜#โ€™) is no longer available. Instead, you are welcomed by a blank line.

Here, I am invoking โ€˜edโ€™ with a blank file (pramod.txt) that I created using โ€˜touchโ€™ command.

Invoking 'ed' editor

The editor responds with โ€˜0โ€™ since it is a blank file. Notice that the cursor on following line is not showing any โ€˜$โ€™ or โ€˜#โ€™ prompt.

2. Appending text:

Now, letโ€™s add 2 lines of text to our empty file.In order to do so, use the โ€˜aโ€™ command (for append). Once you type โ€˜aโ€™ followed by ENTER, โ€˜edโ€™ will wait for your inputs silently. It continues to store the inputs received in the buffer memory till the time you signal it to stop doing so by entering a โ€˜.โ€™ by itself on a blank line. Here is an example:

Appending text

3. Reviewing file content:

In order to review the contents of a file, use the command โ€˜,pโ€™. This will list out the entire contents of the file loaded in buffer, and allow you to review the same.

Reviewing file content
If you want to review specific lines in the file instead, simply type the corresponding line number (First line is line # 1).

Reviewing specific lines

4. Deleting a particular line:

If you want to delete any specific line, type in the line number followed by โ€˜dโ€™. E.g., in the screenshot shown below, I have deleted the first line, and am then listing the file contents using the โ€˜,pโ€™ command:

Reviewing updated file content

Notice that on reviewing the file contents after deleting the first line, I am only shown the 2nd line (which is what remains in the buffer memory).

5. Saving changes:

After having worked on the desired updates, donโ€™t forget to save the changes to the disk by using the โ€˜wโ€™ command. If you exit the editor without saving your changes, the same will be lost. Once you issue the โ€˜wโ€™command, โ€˜edโ€™ will respond with the updated character count for the file.

Saving changes

6. Exiting the editor:

Once you are satisfied with the updates to file content and want to return to the shell command prompt, use the โ€˜qโ€™ command. Once you issue this command, you will be returned to the shell, and you can view the updated file contents using โ€˜catโ€™ command.

Exiting the editor

Thatโ€™s it for now. Do remember to use โ€˜wโ€™ command to save your changes before exiting the editor otherwise your changes wonโ€™t be saved, and the file on disk will remain unaltered.

Thanks!

editor Article's
30 articles in total
Favicon
Implementing Image Upload in React Quill
Favicon
Lazyvim version 14.x in WSL
Favicon
Adding and Customizing Tables in React Quill
Favicon
C Development with GNU Emacs
Favicon
Building a Real-Time Collaborative Text Editor with Slate.js
Favicon
SLATE Code editor with highlight
Favicon
Emacs, a simple tour
Favicon
AI Video Editor: Revolutionizing Video Editing
Favicon
Choosing the editor for the next decade
Favicon
Effortless Formatting for OpenTofu Files with LazyVim
Favicon
Store and Run your Javascript Online - tryjs.online
Favicon
Chosing the right code editor: A quick guide
Favicon
Magic Spell - An AI-powered text editor built with Next.js and the Vercel AI SDK
Favicon
Easy Access to Terminal Commands in Neovim using FTerm
Favicon
Encrypted Note Editor App In React Native
Favicon
Fully featured, modern and extensible editor
Favicon
Set Up Neovim with kickstart.nvim on Mac as a Vimginner
Favicon
Working with Zed for a week
Favicon
Guide to using โ€˜edโ€™ editor in Linux
Favicon
Elevating Your Video Editing Experience
Favicon
How do you use your VSCode profile?
Favicon
Live Editor with React, Quill, and Socket.IO
Favicon
The Spectacular Transformation: VFXโ€™s Role in Redefining Cinema
Favicon
The Evolution of Emacs: A Journey Through Time
Favicon
React Markdown Editor with real-time preview
Favicon
Online Code Editors
Favicon
A light weight code editor that helps as to code efficiently & swiftly in a 360 world
Favicon
I created overbyte - An Online code editor
Favicon
Build a Neovim plugin in Lua ๐ŸŒ™
Favicon
Helix and Zellij

Featured ones: