Edit text conveniently in a terminal window with Slap
Getting Started
Getting started with Slap is not difficult. After launching the program, you can conveniently navigate the file tree with your mouse, including scroll support. However, if you open directories with a large number of files, smooth scrolling suddenly deteriorates into an annoyingly jerky process. The ability to jump to files with names that start with specific letters by pressing the matching keys is something that Slap, in contrast to other applications, currently does not offer.
My tests revealed another weakness when I dumped new files in the background into the directory I was currently viewing in the Slap file view: Slap did not immediately see these files; in fact, I needed to change to a different directory and then back before the files finally appeared.
When you open a file, its content is displayed in the right-hand part of the window. In the lab, opening a file took quite a while in some cases; this was particularly true of files with a large volume of source code, which took Slap a couple of seconds to enable syntax highlighting.
After loading in full, you can start editing directly. Pressing F2 lists the most frequently used hotkeys (Figure 2). Table 1 lists the hotkeys and a couple of other shortcuts as a reference.
Table 1
Hotkeys in Slap
Key | Function |
---|---|
F2 |
Show help |
Ctrl + Q |
Quit the editor |
Ctrl + O |
Jump to the navigation panel and open a file |
Ctrl + S |
Save file |
Ctrl + F |
Start search |
Ctrl + G |
Go to the stated line |
Ctrl + Left arrow |
Jump one word to the left |
Ctrl + Right arrow |
Jump one word to the right |
Ctrl + Up arrow |
Move one line up |
Ctrl + Down arrow |
Move one line down |
Ctrl + A |
Go to the start of the line |
Ctrl + E |
Go to the end of the line |
Ctrl + M |
Go to the matching bracket |
Ctrl + W |
Delete the word to the left of the cursor |
Ctrl + Del |
Delete the word to the right of the cursor |
Ctrl + K |
Delete the current line |
Ctrl + C |
Copy selected content |
Ctrl + V |
Insert the clipboard content at the current position |
Ctrl + X |
Cut the selected content |
F10 |
Show or hide the navigation pane |
Ins |
Change to edit mode |
After opening an existing file, or after completing a fair amount of typing, you can press the left mouse button to navigate through the lines and words. Alternatively, you can use the arrow keys in combination with the Control key. To jump to a specific location in the file, you can either search or specify the line number.
To delete a specific line, use the hotkeys or the mouse to navigate to the line in question and press Ctrl+K to remove it. Alternatively, you can select the whole line with the left mouse button and then press the Delete key twice: The first key press deletes the content, and the second deletes the line itself.
After just a few minutes, you should be familiar with the controls, characterized by a balanced mix of keyboard shortcuts and mouse movements. Editing text is easy enough, but trying to insert long lines of text in the editor can be annoying. Because Slap has no automatic line wrap, you need to move the cursor to the end of the line to see all the content. If you decide to copy and paste content, you will be pleased to see that the familiar keyboard shortcuts Ctrl+C and Ctrl+V take on their normal roles.
Configuration
In the style of Vim, which may be familiar to you, Slap also has a configuration file with various customization options. If you use the editor frequently, take a quick look at slap.ini
(Figure 3), which you will find in /usr/lib/node_modules/slap/
. The content of this file defines the hotkeys, the interface colors, and the syntax highlighting.
Editing this file directly is not a good idea. If you want to modify some of the functions to suit your own needs, the cleaner (and – in case of an update – safer) approach is to edit the .slaprc
file that Slap creates in your own home directory when first launched. To do so, open the file with any editor (e.g., Slap) and type the values you want to change. Make sure you break your personal configuration file down into sections as in the slap.ini
template. Note that copying the selected content from the system global configuration to ~/.slaprc
and then modifying its content is the fastest way to create your own configuration.
Essentially, you can modify any values – including the hotkeys – to suit your needs. The exceptions are the shortcuts stored in the slap.ini
file, and anything the terminal would consider to be an escape character. Figure 4 shows an example of what a custom Slap configuration can look like – the modified configuration is already active in the figure.
Conclusions
The Slap text editor with its JavaScript underpinnings takes an unusual approach but is a welcome change to text editors without mouse support. The mix of familiar hotkeys and mouse support lends itself to efficient and convenient editing.
Navigation is okay for the most part but shows a couple of weaknesses here and there. This fairly young editor still has some potential for improvement. For example, performance drops when you edit larger files.
Although the author claims similarity to Sublime Text [7], I found very few likenesses in the lab. The original is more powerful and mainly targets experienced power users and developers.
Wherever you look, though, Slap impresses with its adaptability, which is why I can unequivocally recommend the editor for newcomers and experienced users alike – at least on your personal workstation. The software is definitely not designed for servers, and you are very likely to get into trouble with the system administrator if you try to install JavaScript just to run a text editor.
Infos
- Nano: http://www.nano-editor.org
- Pico: http://www.washington.edu/pine/
- Slap: https://github.com/slap-editor/slap
- Dan Kaplun: http://beardtree.com
- First commit for Slap on GitHub: https://github.com/slap-editor/slap/commit/de718604ca4a2ca85f4cf83cb1aac405458f5cf3
- Slap README: https://github.com/slap-editor/slap/blob/master/README.md
- Sublime Text: http://www.sublimetext.com
« Previous 1 2
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
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
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.