Snippet tools are incredibly useful. The idea is to save time that would have otherwise been wasted typing phrases, sentences or entire paragraphs.

Espanso default

Espanso is an open source text template program for Windows, Mac and Linux that helps users save time.

During the installation, you have the choice to add Espanso to "PATH" (Windows System Variable) and to enable it to auto-start with Windows. You will also need to restart the computer to get the program working. properly; I think it requires the restart to enable the "PATH" correctly. Start the program and you should see an icon on the system tray. Right-clicking on it allows you to disable it or exit the program.

Espanso icon

Espanso works in all applications that I tried it in including Notepad, Word, Firefox, Thunderbird, and more.

Matches

Espanso uses the concept of Matches (keyword recognition) i.e., when you type a word that's present in the program's settings, it triggers the application to substitute the keyword with its configured replacement. The official wiki explains the technical details rather well, but I'll demonstrate how it works below for your convenience.

Fire up a text editor or browser, or any other program that accepts text input. Type the word :espanso and it will magically be replaced with the phrase "Hi there!". In this case ":espanso" is the keyword and "Hi There" is the replaced text.

espanso demo

If you haven't guessed it already, Espanso is the Italian word for Expanded.

So, how do we customize Espanso?

Go to the application's "Roaming" folder in your User directory. For e.g. C:\Users\Ashwin\AppData\Roaming\espanso

This folder contains a "default.yml" file. Open it using a text editor, e.g. Notepad works just fine. Espanso uses YAML syntax, which is very user-friendly. Look at the highlighted section in the screenshot below. That's the match trigger and replacement which I mentioned in my example.

espanso highlighted

Rules

The indentation is necessary for the syntax to work. So if your match isn't being triggered correctly, check the spacing in the syntax. The other rule is to remember to use the : symbol. For e.g. :espanso vs espanso. The first one is correct, the latter won't trigger the program.

How to add new words to Espanso?

Let's try adding a new one. Write a new trigger word and choose a replacement phrase. To make it easy, you can just copy the "espanso" trigger, paste it in a new line and edit it.

- trigger: ":ghx"
replace: "gHacks.net"

Save the document, exit Espanso and start it again. Now type :ghx and it should be replaced with gHacks.net. That's incredibly easy, isn't it? You can use it to add email signatures, URLs, HTML Tags, commonly used phrases, responses, etc, and save some time.

Espanso is an open source text expander for Windows, Mac and Linux

- trigger: ":emailid"
replace: "email@example.com"

- trigger: ":ggl"
replace: "https://www.google.com/"

- trigger: ":myadd"
replace: "Apt 123, 5th Avenue"

- trigger: ":tvm"
replace: "Thank you very much"

espanso examples

You can even replace a text with an image, the syntax is slightly different.

- trigger: ":word"

image_path: "/path/image.ext"

Replace word with the keyword you want and the /path/image.ext with the full path of the image's location, followed by the name of the picture and its extension. This may not be practical in day-to-day usage, but the option is there, in case you want to use it.

All the above examples are static matches, as in, the replacement word or phrase never changes.

Will it replace other words which I type? No, that's why the : symbol is used, to prevent words being replaced by accident. You can use matches without the colon symbol, but it will replace words which spell similarly. Refer to the official documentation about Word Triggers to avoid this issue.

Dynamic Matches

These are matches with variables, e.g. to replace the variable with the date and time.

espanso extensions

Look at YML document's "Dates" section; this one has a trigger that will add the current date in the format "month/date/year (US format). The syntax for it may appear to be complicated, almost like a program code. First you set the keyword as usual, then you declare a variable called "mydate", which contains the type (extension) and the parameter to calculate it. The documentation I linked to above, explains how to add a match for a similar "Time" match.

Note: I use the word section just as a reference to the order of the commands that the default configuration file lists them in. You can write your matches in any order you want to.

Extensions

Espanso supports extensions, commands that you can customize. The Date example which I mentioned uses the "Date" extension. You can set an extension by using the "type" command followed by its own syntax.  The third section in the YML document lists a Shell Command that you can use for that purpose.  The Shell extension lets you write commands that can be executed using the Command Prompt, PowerShell and other shells. The application's Script extension is used to execute scripts that you supply.

The application is written in Rust (Mozilla's alternative to C++).

Espanso is fast, easy to use if you want to quickly insert words and phrases. When it comes to variables I don't think it is user-friendly, BeefText has variables built-in, just right-click and select the one you want to use. On the other hand, you can create custom variables with the former.

Thank you for being a Ghacks reader. The post Espanso is an open source text expander for Windows, Mac and Linux appeared first on gHacks Technology News.



Post a Comment

Previous Post Next Post