Nice but Powerful Command Line Editors as Alternatives to Vi and Emacs

/pics/misc/ne-micro-kaa.jpg

Lots of Linux beginners face at one point or the other the problem that they have to change a small configuration inside the command line. There is no Notepad, IntelliJ, Eclipse, and not even Gedit or Kate available here.

And very often the default is vi (or it's iMproved version vim). Vi has an edit and a command mode - and starts in the latter. Therefore, most beginners will experience an extreme amount of anxiety when they cannot edit anything nor even exit the program.

On the Raspberry Pi, people usually suggest to use nano instead of vi - some people try Emacs, but also in emacs, the usage feels very unusual, if you are used to the rich GUI editor experience. I do not want to start a flame war here - I have used Emacs myself in my young years and abandoned it it after destroying my perfect configuration (Emacs makes you love the possibility to customize it for your unique specific needs) the second time during an upgrade. And no, at that there was no git yet to keep nicely track of your configuration changes (yes there were rc and cvs, but this is for another post).

I recently stumbled upon Spacemacs and tugged it away for taking a closer look later at it. It turns out to be a heavily configured version of Emacs adding a lot of Vim features to Emacs and lessening the customization effort and wish going along with Emacs. However, all Vim, Emacs, and Spacemacs have still an extremely steep learning curve and do not transfer to anything else in the editing world or back from it. They come though with lots of tempting features - especially interesting for developers, web designers, and bloggers. They also run basically in any type of command line. Even on Android under Termux they provide a powerful command-line editing and development environment on your phone. As I vowed to be more active on my techblog, I wanted a nice command-line-edit way to give me quick and powerful editing support in all the environments where I could potentially write. And yes, I actually often like to edit in the command line. My quick and always available editor is mcedit, which is part of Midnight Commander. Midnight Commander is a very powerful file manager for the command line and even if it is inspired by the Norton Commander dual panel interface from the DOS ages, my systems students still seem to appreciate it as a very easy to use exploration and file management tool today. It happens to come with a built in editor, which very well supports keyboard and even mouse and touch input and has syntax highlighting. Not much more, but very often that is all I need. It is part of nearly all Linux distributions (on Debian, Ubuntu, Mint it is just a sudo apt-get install mc; mc away) and for accessing the editor, you can then type mcedit at the command line.

However, Midnight Commander and respective mcedit as well as nano had a little too few features for making me happy in all my command line editing tasks. Therefore, I started to look for alternatives. Of course, I took another look at vim and emacs, but I am still not feeling comfortable to recommend these to everybody. That's why I was looking for something nicer and easier to learn. I was especially interested in syntax highlighting and extensibility and support of macros or external tools. I also wanted them to be still in development and having some kind of community support.

Three candidates stuck out: ne, the niceeditor, micro, and kaaedit.

/pics/misc/screenshot-ne.png

ne or nice edit is actually really easy to use. It is very easy to open up the menu (press F1 or alt-M) and look up powerful commands to edit. Most Linux distributions and also cygwin include it, so it might be as easy as sudo apt-get install ne to get it. It does not support mouse input like mcedit (and later micro), but of course this should not be the major focus of a command line editor. It does syntax highlighting and allows to create macros with an inbuilt recording function. It feels very natural to use, I wish I saw a way to add spell checking to it. Unfortunately, it does not support restructured text as highlighted text. Because of its availability I think this should definitely be a consideration for replacing nano.

/pics/misc/screenshot-micro.png

micro claims to be "a modern and intuitive terminal-based text editor". And, I can confirm this is spot on. It is not part of any major Linux distribution yet, but it comes as a relatively easy to install static binary (which you can also compile yourself). You basically can just copy it (as root) to /usr/local/bin and are ready to go. It supports syntax highlighting, normal editing commands, mouse input and selection, F1 brings you to a quick start screen for telling you that you can exit with ctrl-Q and access advanced commands with ctrl-E and a tab command extension. After using it for a couple of minutes, editing feels very natural and you forget that you are actually in a command line environment. It supports very nice color schemes and overall has a very clean and streamlined feel to it. You can write powerful plugins in the LUA programming language and there is support for compiling and running your programs. There seems to be easy support to add command completion, but I did not test this yet. I did though not find any on the fly spell check in here - maybe it can easily be implemented by a plugin. I will keep a close look for command completion and that as I have the feeling that it should come very soon - I would definitely consider switching every command line editing to micro, when spell checking would be available. Like ne, it also has only very limited syntax highlighting support for restructured text. Functionality wise it feels very similar to ne, but the supporting community seems to be bigger and the whole usage feels a bit more clean than ne.

/pics/misc/screenshot-kaaedit.png

The other really interesting text editor I found is kaaedit. It feels again very similar to ne and micro but seems to offer a little less in terms of functionality. It is however fully coded in Python and also extensible in Python. This might make it very accessible for a community to provide plugins. Because of these roots it supports of course syntax highlighting for restructured text. No mouse support or spell checking here either.

As a summary, micro made the best impression on me. I would definitely prefer ne to nano and vim (even if vim will have everything from spell checking to syntax highlighting of restructured text - but I still don't see how I would convince a significant amount of people to use it). kaaedit though is really tempting as I have the feel, I could make some changes myself to it and due its already present restructured text support.

This article got much longer than I expected - what can you write about text editors anyway? If you are still bearing with me until here, please feel free to leave your opinion or experience with any of the presented editors in the comments. Also let me know if I have overlooked another nice and easy to use option. Also pless express some encouragement if you want me to take a more in depth look at the gui options or if it would make sense to turn this into a Youtube video.

Here is again a list with all the links:


As I have worked at the same time for comparison with some small lightweight gui alternatives, I should mention at least the direct gui contenders (big advantage: most of them do on the fly spell checking). The honorable mentions for lightweight but still powerful GUI editors are:

  • geany: nearly a full IDE, great plugins, runs even in Windows and one of my favorite small cross platform editor.
  • gedit: small, fast, simple
  • kate: KDE's hidden gem for editing code
  • atom: a new upcoming contender, very extensible,also nearly full die, very active community
  • retext: no on the fly spell checking, but comes with fast preview for Markup languages (markdown and restructured text,which is the base for this blog)

Resources I visited and read for this investigation:

Taming Chrome - Control tabs memory and free space for your work

tab suspender screenshot

Ever seen what a beast Google Chrome has become? I started monitoring that it easily took 2-3GB of my main memory sometimes and was really bogging my system down. Running Android Studio or Pycharm need quite some memory too and things got actually killed by the system once in a while, making me yet again re-consider Firefox.

Firefox never had this issues as it only loads opened tabs, when you re-visited them. You might think having 30-50 tabs open in one browser session is a sign of miss organization, but I like to think it has to do with the fact that I always work on several projects (teaching and 1-2 research projects and recently also blogging again) all opened in different windows.

So isn't there a way to keep all these tabs open without consuming 100-200MB each?

Yes there is, check out the Chrome extension Tab Suspender. And, yes it does the trick, It still consume 200MB for 40 tabs, but that's much better than Gigabyets. The difference browsing with more than 10 tabs is striking. After a while of inactivity in a tab it replaces it with its own link and grayed-out image (see supplied screenshot), you need to click it once to wake it up, should you visit the page again. Everything is stopped on the page and the memory consumption considerably reduced.

If you Google for Tab Suspender, the first hit is actually The Great Suspender. I haven't actually tried it as the last update listed on the Chrome Webstore is from 2015. However The Great Suspender actually is open source and here is its github page. It also has many more ratings than Tab Suspender. Github shows recently filed issues, but no activity on the project since November 2016. So, if you use Tab Suspender, please share your impressions down in the comments.

Issues installing isso as replacement for disqus and how to solve them

Due to extreme trouble with disqus (compare previous posts), I switched my discussion and commenting system to isso.

My server runs at this point Ubuntu 16.04 and therefore you can either use the available isso package (just do apt install isso) or install a newer package from an external source as described here.

Both sources have similar issues: they do install well, but most of the networking and startup related options in the respective configuration options are wrong or described at wrong locations. As the native ubuntu package didn't work for me, I describe here the way how I installed the package from the external source. They ask you to install the key with apt-key add, however as curl falls in a trap downloading the file, and therefore I suggest downloading the file manually with your browser and then install it locally like this:

cat /tmp/downloaded.key | apt-key add -v

You can follow the rest on that page.

Now make sure to have gunicorn installed (apt install gunicorn) and create a file /etc/isso.conf - use this here as a base and configure as described here. Just remember that the local server will always run on localhost, port 8000 independent of what you configure here or in /etc/default/isso.

Make sure that both isso and Nikola either run normal http or both ssl only and let your isso run on a virtual server with a name like comment.yourserver.tdl. In my case isso runs on https over ssl on comment.ulno.net and my webpage (as you know) on ulno.net. However, as described in a previous post, I redirect now also normal http requests to https. To make this work correctly, you might have to create a valid certificate (you can get a free one and a decent description how on http://letsencrypt.org).

In Nikola specify COMMENT_SYSTEM = "isso" and COMMENT_SYSTEM_ID = "https://comment.ulno.net/" (Adjust ulno.net to your sever!) and recompile your blog.

Start isso with systemctl restart isso, eventually restart your web-server (nginx, apache, or lighttpd) and enjoy comments without spying from a system that you can eventually even debug if some things do not work.