💾 Archived View for warp.geminispace.club › ~freezr › gemlog › 2021-06-03-micro-editor.gmi captured on 2024-05-26 at 14:48:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

-=-=-=-=-=-=-

Looking For a Neat TUI Editor with Modern Features?

One of the thing that has been stopping myself to release this capsule has been the lack of a discreet, easy to use, Gemini-friendly editor.

Gemini doesn't require any complicated formatting however I write mainly in English, which is not my native idiom hence I really need an active spellchecking as help, but even if I was writing in my language orthographic errors happen anyway.

The majority of the default GUI editors available on Linux (and probably FreeBSD) do not provide a spellchecker functionality and most of the time do not provide the Gemini markup yet; thinking to use a software like LibreOffice Writer is totally out of discussion. As a matter of fact many TUI editors already provide both the functions but have a steep learning curve which makes people giving up pretty soon.

However a new editor tries to solve all this common issues...

What's New on the Block, Dude?

Recently a new TUI editor is came out with interesting features that make it easy to use also for the general public, albeit some customization aren't really intuitive and I needed quite time to figuring out how to setting up everything properly!

Micro is What You Need for Your Gemini Capsule!

If you don't dislike using a terminal but, like me, do not have a programmer mindset that makes easy using programs like Vim or Emacs, Micro is what you need to write down your content easily and distractions free!

Micro - a modern and intuitive terminal-based text editor

Micro is very handy, it works with mouse, you can select and copy text with mouse or keyboard with the usual CTRL+C/X/V bindings; it can split the buffer vertical and horizontal, it has tabs and much more stuff. It resembles a classic GUI editor into a terminal but with all the feature that TUI editors usually provide.

Micro can do a lot of things and it is very flexible and expandable but what I needed it was just syntax highlighting for Gemini Markup and real-time spellchecking, hence besides those I will not explore this editor further.

Installation

Currently version 2.0.8 is available in all the major OSes like Debian/Devuan, OpenSuse or FreeBSD, you can install it through each specific package manager, however 2.0.9 provides further improvements that you would not miss at all. To install it on your Linux machine just enter in the folder you like and copy and paste this command:

You may need to install before "curl"

curl https://getmic.ro | bash

Then you can launch it with the usual command:

./micro

I created an alias to run micro 2.0.9 as micro2 since I installed 2.0.8 through my package manager.

Setting up Micro for Gemini

By default 2.0.8 and 2.0.9 do not provide the feature I need already enabled, especially 2.0.8 requires to add the Gemini's syntax manually, thus I strongly recommend using directly 2.0.9 provided by the author while it is not available on your OS repos.

Adding the Syntax for Gemini Markup

If you prefer still using 2.0.8 to highlight the syntax you have to create a "syntax" folder in your ~./config/micro/ and then creating a file inside called: "gemini.yaml"

micro ~./config/micro/syntax/gemini.yaml    

And now simply copy and paste the code below just to realize how handy it is (CTRL+S to save):

## Gemini syntax

filetype: gemini

detect:
    filename: "\\.(gmi|gemini)$"

rules:
      # link lines
    - constant: "^=>[[:space:]].*"
      # preformatted text lines
    - special:
        start: "^```"
        end: "^```"
        rules: []
      # heading lines
    - special:  "^#{1,3}.*"
      # unordered list items
    - identifier: "^\\*[[:space:]]"
      # quote lines
    - statement:  "^>.*"

The source:

https://github.com/zyedidia/micro/blob/master/runtime/syntax/gemini.yaml

Installing the Aspell Plugin

Micro comes with a powerful plugins system with many plugins already included by default and some other available separately: like the Aspell plugin. A list of all the plugins available is here:

https://micro-editor.github.io/plugins.html

To install the Aspell plugin just copy and paste this command inside the terminal:

micro -plugin install aspell

You can run Micro and check the status of the plugin internally using the CTRL+E combination and digit the following command after ">"

plugin list

It will show up all the plugins available by default and the ones installed manually.

Information about the Aspell plugin are available here:

Aspell: Main Page

Aspell: Help Page

You can activate the plugin directly from the command line or storing its configuration in the settings, so far it looks you can't pass more than one language and dictionary at the same time. If I will receive any update about the latter I will updated this post.

Basic Settings for GMI Files

Now that Aspell is installed you may probably noticed that by default Micro doesn't wrap long lines, you have to change the default settings to wrap them (again 2.0.9 has better control over it). To make changes to the default settings you have to modify the file "settings.json" inside "~/.config/micro/"; below my (very basic) setup (any suggestion to improve it is welcome):

{
    "*.gmi": {
        "aspell.check": "on"
    },
    "*.txt": {
        "aspell.check": "on"
    },
    "fileformat": "dos",
    "ft:markdown": {
        "aspell.check": "off"
    },
    "keepautoindent": true,
    "softwrap": true,
    "wordwrap": true
}

A complete list of all the options available can be viewed through Micro itself or checking out this link:

https://github.com/zyedidia/micro/blob/master/runtime/help/options.md

My Custom Setting

I messed up a bit ended up with these settings:

{
    "*.gmi": {
        "aspell.check": "on"
    },
    "*.txt": {
        "aspell.check": "on"
    },
    "colorscheme": "gruvbox-tc",
    "fileformat": "dos",
    "ft:gemini": {
        "aspell.check": "off"
    },
    "ft:markdown": {
        "aspell.check": "off"
    },
    "ft:unknown": {
        "aspell.check": "on"
    },
    "keepautoindent": true,
    "softwrap": true,
    "wordwrap": true
}

Just About Themes

The default theme is nice but too much green-ish for my taste, there are several themes available to set up any of them just enable the Micro prompt with CTRL+E and then write:

set colorscheme [tab]

Use TAB to scroll over all the themes available I am currently using "gruvbox-tc" which is warmer.

Wrapping This Up

This short walking-thru does not pretend to be complete by any means, it is basically a personal memo, however now if you had my same doubts you should be able to type with Micro as any other word processor without missing any typos. If you want share with me a better settings solution please do not hesitate to write me at:

freezr AT disroot DOT org

↩ go back