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
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.