Search

Meet the Text Editor used by Linus Torvalds

Available on GitHub and kernel.org


Meet the Text Editor used by Linus Torvalds

Most people like to know what geniuses use to try to get closer to the masters.

The text editor that Linus Torvalds uses is one of the Emacs family, more precisely a modified version with specific (and private) lines to your liking. A modified version of MicroEmacs he called uEmacs.

Introduction

The uEmacs license is free-noncomm, that is, it is free, but you cannot use it for commercial purposes. It is called uEmacs/PK , I don’t know why that PK in the name, but I read that it was incorporated by Petri H. Kutvonen, University of Helsinki, Finland. Maybe this acronym PK is the initials of the names of this guy who was quoted.

According to Linus Torvalds himself, he decided to modify it because MicroEmacs had an update and modified some things he liked from version 3.9 (“The best MicroEmacs ever” — Linus Torvalds), so he created his own version that has many of the features of this version(3.9) with a few more things added by it.

Installation

uEmacs is available on GitHub and also kernel.org. I can’t tell if your distribution has it in the repository, unless you have a Gentoo that has pretty much everything in the repository when it comes to developer tools!

So, to install using Portage, just run the command:

sudo emerge app-editors/uemacs-pk

For other distributions you can clone the uEmacs repository and compile, but first remember to have the Ncurses development library, in addition to the binary build software: make and gcc. Examples:

sudo apt install ncurses-dev # Debian, Ubuntu, Mint,...
sudo dnf install ncurses-devel # Fedora, Red Hat,...
sudo pacman -S ncurses # Arch, Manjaro, ...

After that clone the repository, it can be:

Via GitHub

git clone https://github.com/torvalds/uemacs

Or via kernel.org

git clone https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git

Now just compile and install, it’s so simple that it only comes with a Makefile

cd uemacs
make
sudo make install

Note: If there is an “error” when compiling, see the additional step, otherwise ignore it!

Additional step if there is an error

Anyone who understands termcap and ncurses knows that there will be an error if we don’t pass the correct parameters to compile.

I, despite using the package compiled by Portage, tried to compile and got the error:

CC tcap.o
   LINK in
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: tcap.o: undefined reference to "tgoto" symbol
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfo.so. 6: Error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:62: in] Error 1

As soon as I read the name of this file and a word from curses.h: tgoto , I already knew what the error was and I fixed it. If you have this same error, do this:

  • Open the Makefile file with your editor
  • Edit the line that starts with the word LIBS that has this content:
LIBS=-lcurses

And add the -ltinfo, like this:

LIBS=-lcurses -ltinfo

I even made a pull request if he accepts it will be about 10 years from now 😃 .

And then compile again: make && sudo make install, the binary is em.

Use

The command to open the editor without any files is:

em

To get help, run em --help, the output will be this:

Usage: em filename
   or: em [options]

      +          start at the end of file
      +<n>       start at line <n>
      -g[G]<n>   go to line <n>
      --help     display this help and exit
      --version  output version information and exit

You can already feel that the editor is very basic, right?! 😃

Some commands

In Emacs style editors you don’t need an insertion command, just start typing and the text already appears in the file!

  • em [file-name] - Opens the file indicated in [file-name], example: em main.cpp;
  • Alt + z - Save and exit;
  • Ctrl + x d(quickly type x and then d) - Quit without saving if you press y to the question: Modified buffers exist. Leave anyway (y/n)?;

And among several other commands you can consult on the MicroEmacs Wiki that also work for uEmacs.

Remembering that ^X means Ctrl + x and M means Alt .

To the next!

References


text-editors emacs linus


Share



Comments