Emacs in Linux is a text-editing application and has been around for 40 years in Linux. It is a feature-efficient text-editing tool that can be run on UNIX, LINUX, BSD, Mac, and even Windows systems. Now, it is not just a text editor, but more like an IDE (Integrated Development Environment).
What is Emacs in Linux?
Emacs stands for Editor MACroS. It was developed in the MIT AI lab in 1976. There are many variants of Emacs in Linux and GNU Emacs is the most widely used Emacs. GNU Emacs is not just an editor but has the functionality of more than an IDE. It has numerous built-in commands and macros and great flexibility overall.
Emacs Lisp Code for Emacs in Linux
LISP is one of the oldest programming languages in the world. Emacs Lisp was developed using the common LISP language but it is very simple and easy to apply even though it is a full-fledged programming language. Subsequently, this language can be used to edit and customize Emacs as you wish. So, this text editor will give you great flexibility and many professionals use Emacs just for this feature.
Emacs Editor Keybindings or Keyboard Shortcuts
Emacs has many shortcuts or Keybindings. These Keybindings are not required, but they help by increasing productivity. So, Professional developers use them a lot. The emphasis of these Keybindings is never to move had from the alphanumeric keys or the normal keys.
To do that, CTRL and ALT are used extensively to apply commands. Here you will find many of the Keybindings present in Emacs.
Emacs Editor Keyboard Shortcuts.pdfA. Movement Keys
These keys are used to move between characters, words, lines, etc. You can use these Keybindings to start using movement keys without taking your hands from the alphanumeric keys.
Emacs Movement Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | CTRL+B | Moves the cursor one character forward. |
2. | CTRL+F | Moves the cursor one character backwards. |
3. | ALT+B | Moves the cursor one word forward. |
4. | ALT+F | Moves the cursor one word backwards. |
5. | CTRL+P | Moves the cursor one line forward. |
6. | CTRL+N | Moves the cursor one line backwards. |
7. | CTRL+A | Goes to the line beginning. |
8. | CTRL+E | Goes to the line ending. |
B. Killing or Deleting Keys
Here are the shortcut keys for deleting or killing characters, words, and lines.
Emacs Killing or Deleting Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | DEL | Deletes a character backwards. |
2. | CTRL+D | Deletes a character in the forward. |
3. | ALT+DEL | Deletes a word backward. |
4. | ALT+D | Deletes a word in the forward. |
5. | ALT+0 | Deletes a line backwards. |
6. | CTRL+K | Deletes a line in the forward. |
7. | CTRL+Y | Yanks back the last thing killed. |
8. | ALT+Y | Replaces the last yank with the previous kill. |
C. Search Keys
You may want to search for some words or characters in Emacs and to do that you can use the incremental search keys quite easily.
Emacs Search Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | CTRL+S | Searches forward. |
2. | CTRL+R | Searches backward. |
3. | CTRL+ALT+S | Regular Expression searches forward. |
4. | CTRL+ALT+R | Regular Expression searches backward. |
5. | ENTER | Exits incremental search. |
6. | DEL | Undo the effect of the last character. |
7. | CTRL+G | Aborts current search. |
D. File Keys
There are also many Keybindings for working with files. Here are some of the file management Keybindings.
Emacs File Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | CTRL+X CTRL+F | Reads a file. |
2. | CTRL+X CTRL+S | Saves a file. |
3. | CTRL+X S | Saves all files. |
4. | CTRL+X I | Inserts the content of another file. |
5. | CTRL+X CTRL+F | Replaces this file with another file. |
E. Replace Keys
You can replace a text with another one using some of these keybindings.
Emacs Replace Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | ALT+% | Interactively replaces a text or string. |
2. | ALT+X regex | Using regular expression. |
3. | SPACE/Y | Replaces. |
4. | DEL/N | Skips. |
5. | ! | Replaces all. |
F. Getting Help Keys
You can search for help in Emacs using the following Keybindings.
Emacs Getting Help Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | CTRL+H | Help window. |
2. | CTRL+X 1 | Scrolls the help window. |
3. | CTRL+H A | Shows command matching a string. |
4. | CTRL+H K | Describes the function a key runs. |
5. | CTRL+H F | Describes a function. |
G. Case Change Keys
Sometimes, you need to change cases to UPPERCASE or lowercase. To do that the following Keybindings can be used.
Emacs Case Change Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | ALT+U | UPPERCASE word. |
2. | ALT+L | lowercase word. |
3. | ALT+C | Capitalize word. |
H. Spelling Check Keys
You can check your text spelling by using the following Keybindings.
Emacs Spelling Check Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | ALT+$ | Checks the spelling of the current word. |
2. | ALT+X ispell-region | Checks the spelling of all words in the region. |
3. | ALT+X ispell-buffer | Checks the spelling of the entire buffer. |
I. Shell Keys
You can use the shell commands in Emacs as well. You can use the following Keybindings.
Emacs Shell Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | ALT+! | Executes a shell command. |
2. | ALT+| | Runs a shell command on the region. |
3. | CTRL+U ALT+| | Filters region through a shell command. |
J. Keyboard Macros Keys
You can create a keyboard macro using Keybindings as well. To do that use the following Keybindings.
Emacs Keyboard Macros Keys.pdfSerial No. | Shortcut Keys | Functions |
1. | CTRL+X ( | Starts defining a keyboard macro. |
2. | CTRL+X ) | Ends Keyboard definition. |
3. | CTRL+X E | Executes the last defined keyboard macro. |
Features of Emacs in Linux Editor in Linux
Emacs is one of the oldest text editors released in the world. It is known for its features and functionalities. Now, Emacs has many features that make it one of the favorite text editors in Linux.
Some of the features that keep it apart from other text editors are as follow:
A. Content-aware Editing
Emacs is smart and understands the type of text written inside the program. For programming codes, it can easily distinguish between language and other text and gives syntax colouring for many different file types. As a result, comes in handy for coding and understanding the logic behind a program.
B. Complete Unicode Support
Emacs supports complete Unicode support. That means you can use any type of known symbols and characters inside Emacs. This turns Emacs into a widely usable text editor that can edit and develop any type of text from basic text to research paper, from basic coding to total app development.
C. Customizable Using Lisp Code
Emacs has a built-in LISP interpreter, which means it can run Emacs Lisp code and make customization inside the text editor. As a result, it is widely versatile and very useful for professionals. Though it has a steep learning curve, it is worth the effort and can certainly give you more options. That’s why many professionals still use Emacs even though it is quite an old text editor.
D. More Than Just a Text editor or IDE
Emacs was originally a text editor, but now it has become more than an IDE. Currently, Emacs can do pretty much anything a general IDE can do. It can compile, run and test most of the most well-known programming languages and work seamlessly. Additionally, Emacs integrates with GDB to provide an IDE and it is widely popular for its multi-purpose usage.
You can even use Emacs as a calendar, file explorer, debugger, and even mail application. Truly, It is a multipurpose application that has become more like an Operating system than just a text editor.
E. Lightweight
Emacs is a lightweight application that can be installed in Linux quite easily. It has a GUI and even a Terminal version as well. So most of the users will be able to cope with its functionality and love the overall seamless usage. As it does not have any bulky heavy form, most users like to work with it for simplicity.
Comparison of Emacs with Other Text Editors in Linux
There are many Text editors available and many of them provide specific advantages over Emacs in Linux. But Emacs also has other advantages and flexibility. So, you just need to use them to find your own cup of tea.
A. Emacs vs Vim in Linux
Vim is another popular text editor and people love it for its lightweight front. That’s because it was mainly developed from Vi. Vim stands for Vi IMproved. Vi was designed for slower Terminals and focused on the minimum number of keystrokes.
- Editing Modes: Vim has 2 different editing modes. Command mode and Insert In command mode, you can type and execute commands. In Insert mode, you can add text to your file. But Emacs has content-aware mode. That means it doesn’t need any other modes. It understands the document type on its own.
- Lightweight: Vim was mainly developed to work on slower Terminals. As a result, Vim is quite lightweight and easy to use. It doesn’t need many system resources. This is great for working in older systems. Emacs on the other hand may not be as light as Vim, but still lightweight compared to many other available text editors. Vim requires less RAM to run.
- Learning Curve: Emacs has an easier learning curve for its easier and more natural interface compared to Vim. Vim on the other hand has different editing modes, making it harder for beginners to learn.
- Customization: Emacs has more customization than Vim. You can use different programming languages to customize Emacs according to your needs. Vim also provides good enough customization capabilities. So, it’s not as large of a deal for most programmers or developers.
B. Emacs vs VS Code in Linux
VS Code is a modern text editor and a full-blown IDE. Presently, It is one of the most popular editors nowadays that many developers love to use for its intuitive interface. Here are some comparisons between Emacs and VS Code.
- Lightweight: Emacs is more lightweight compared to VS Code. VS Code implements many functionalities and a complete IDE that may not run well on older systems. Additionally, It may take a lot of system resources. But Emacs is more optimized and can run on many systems quite easily regardless of the age of that system
- Customization: Emacs is considered to be more customizable than VS Code. VS Code is not bad in any comparison, but in Emacs, you have KeyBindings and Emacs Lisp codes to customize pretty much anything.
- Navigation: Emacs can be used for file navigation and mail checking and many other things we do in our Operating system. But, VS Code has some limitations in that case. Yes, some level of communication in the file manager is possible, but not even close to what is possible with Emacs
C. Emacs vs Nano
Nano is a built-in simple text editor in Linux. It was built for the purpose of simplicity so that pretty much anyone can start using it with little to no knowledge beforehand. But, to do that it also had to sacrifice some functionality. Here are some comparisons between nano and Emacs.
- Simplicity: Nano is very simple. As a result, there is pretty much no learning curve. As a result, there are simple shortcuts displayed at the bottom and that’s it. So, beginners will need less time to get used to Nano.
- Features: As Nano was built for the purpose of simplicity, it had to sacrifice many functionalities as well. So, It doesn’t have many features to compete against a well-rounded text editor like Emacs.
- Customization: Nano doesn’t have many customizations. Its main use can be editing some config files or doing some small edits to a text file. But, for any type of coding and development, Nano is simply not as powerful and its customization capabilities are also very limited.
Conclusion
Emacs in Linux is a popular text editor and many professionals use it as a daily driver. Certainly, it has immense functionality over other text editors or IDEs and has more customization than many heavy IDE as well. Besides, It has a lot of Keybindings and they can improve functionality as well. But, that doesn’t mean you need to memorize all of them. Just try it out and practice. You will get used to it and love it after the steep learning curve.