-
Notifications
You must be signed in to change notification settings - Fork 4
Getting started
TextEd is a command-line text editor for Linux, inspired by the command-line editor ed, but with a simpler and more intuitive interface. It can be installed via the packages available in the various releases or by following the instructions for installing it available in the README. Once correctly installed, TextEd can be launched with the command:
$ texted
If you do not specify a file name to open, a.txt
will be assumed by default. To open a file, type its name after the command texted
.
Once in the editor you will be presented with a similar screen:
At the top we find a yellow sign welcoming us, informing us which version of the software we are using. On the next line, a text indicates the name of the file and the current line selected. The green color indicates that we have permission to write to and read from the file. From here we can enter commands to start writing and editing our file.
Typing the command i
will enter insert mode, a mode that allows us to enter text until we press the ESC key. To exit you must press enter after typing the ESC key. What we have written is just saved in memory until we perform a write operation.
Note that if the file was not empty, what we have written will be concatenated with what was already written, without the program inserting spaces or newlines.
Once the text has been entered we can display it with the p
command and its variants. To learn more about the print command, type h
, which will output a list of useful commands we can use grouped by affinity, followed by a brief description.
Suppose the second line doesn't satisfy us: now we want to change Here is the second line
to Here here we go with the second line
. Nothing could be simpler. The s
command replaces one expression with another. We can use it by writing:
> s/expression to replace/new expression/
But be careful, the number next to file.txt
tells us that we have selected the first line. To edit the second line we will have to move to this one. To do this, just use the command l
followed by the number of the line you want to move to. In our case we would write:
> l2
or alternatively:
> l 2
Finally, we reprint the file to check whether the change has been made correctly. Here is the result:
Let us now imagine that we want to add a full stop at the end of the first line. This is done with the a
command, which adds text to the end of the selected line. Let's move to line one and type:
> a/.
And print the result with p
.
And, as a last resort, let's imagine we want to edit the third line to read And I really want to add a third line, too!
. To add really
before want
, we can use the m
command as follows:
> m/before/add /
Note that if you don't put the space before the final slash, the two words will be spelled together without any spaces. This is not a big problem, we can always add a space with this same command, by writing:
> m/before/ /
Note: To navigate through the history of already used commands you can use the arrow keys
To save the file, simply use the w
command. We can then exit by typing q
. If we anticipate that our next move after saving is to exit, we can use the x
command to save and exit.
When we save, the program tells us how many bytes have been written to the file.
Texted allows us to execute a command from bash. To do this, just use !
followed by the command you want to use. Let's try removing the file from texted using the rm
command.
As you can see, the program is able to recognize that the file has been deleted and warn us. But don't worry, texted will load the whole file into memory, so if you want to recover all the lost data, you can save the file with the w
command, and it will reappear as if it had never been deleted. This will not be possible once you close texted.