What’s your favourite text editor? In a recent blog entry I updated “The Script” for IOT fans and as usual, got myself incredibly frustrated with the lacklustre “Nano” editor that comes with Raspbian on the Raspberry Pi, only to discover that my backup editor “MCEDIT” is really only marginally better – this stuff is built primarily to please Linux fanboys and IMHO is not in the same ease-of-use league as NotePad++ on the PC – granted the latter is in a Windows environment and these are command line tools – but surely there must be something better?
There IS – I just found it at the weekend. I’ve added this to “The Script” today. The line below starts off the MICRO editor with (for example) script.sh opened in the current directory for editing.
./micro script.sh
I love the editor already – and it has proper control-C and control-V for copy and paste respectively. Open a readable file to play with and dive straight in… control-E brings up help at the bottom of the screen – and if you want to set up a theme – for example:
set colorscheme simple
Note that at this point, the colours are a bit basic – more on that toward the end – but first – to install this little wonder of an editor… Sitting on your PC running an SSH session (I use Mobaxterm) to the Pi as user pi (if you are using a Raspberry Pi)…
curl https://getmic.ro | bash
And of course true to my claim to being bone idle, I’ve updated the /etc/bash.bashrc file to have that “./micro” reduced to “e” (“ed” has already been taken) – I’ve also added the privileged version which I’ve called “se”.
And here they are added to my list of aliases in ./etc/bash.bashrc
Having mastered control-V for INTERNAL pastes, I noted that EXTERNAL pastes from Windows did nothing so I added the following:
sudo apt install xclip
External pastes seem to take half a second to appear but no matter. Full mouse support etc.
So now I had shortcut se for using the editor as SUDO (ie privileged user) – and that’s lovely but still the editor colors were boring compared to modern Windows editors.. the solution is to add 2 environment varibles to the end of /etc/profile using the new editor shortcut – add the two lines right at the very end of the file….
se /etc/profile
export MICRO_TRUECOLOR=1
export COLORTERM=24bit
and save using control-S then F10 to exit. You should reboot the PI for ease after setting these two variables… then, again in the editor – hit control-E then for example:
set colorscheme dukedark-tc
and the result when editing my script.sh
Rather than explain more here, I will just pass you to the editor’s home page – read all about it:
https://micro-editor.github.io/
There are two issues I’m aware of with this editor – selecting offscreen and a disappearing cursor in 24-bit colour mode – I’m commenting in Github right now and a nightly version of micro fixes the former – as for the cursor – not yet. To get the latest version – for your computer you may need a different file if not a Raspberry Pi – there are Windows and many other nightly builds all in the same place…
wget https://github.com/zyedidia/micro/releases/download/nightly/micro-2.0.4-dev.15-linux-arm.tar.gz
tar xvzf micro-2.0.4-dev.15-linux-arm.tar.gz
That will create a folder with the micro editor file in it (micro) – I simplified the folder name they used down to simply “micro”. – ultimately I simply pulled the binary file into my PI folder so back as it was originally.
Comments below, please.
Hi all, you may be interested to know that Microsoft’s free, cross-platform code editor Visual Studio Code (VScode) now also has remote editing capabilities so you can stick with your best and favourite editor and IDE while editing things remotely. You even get a remote shell right in the editor. Integration with most VScode extensions, run npm and other configured scripts from the UI and a lot more.
Not so useful for the occasional quick tweak of a file but great for more extensive edits and perfect for node-red.
I now use it to do remote edits of front-end code for uibuilder (web interface builder for Node-RED).
Julian
So I have VSCODE open on my PC – how does that access a file on the PI and edit it?
Providing you have an open-ssh server installed on the pi and the open-ssh client on your windows pc then it is just a matter of installing the VSC – Remote SSH extension on the PC – this gives more detail https://code.visualstudio.com/docs/remote/ssh
Yup, it works – thanks Steve…
Sorry Peter, mail system junked the reply notifications. Glad you got it sorted.
Amazing. And I didn’t even know this existed!
I tried it out and am in love. I agree 100% with Pete re nano and Antonio with “learn VI so you can use it, then install a nicer editor”
You just have to know the most important VI(M) commands a bit to get around on Linux until you can install a nicer one, as it usually is the only editor available, which is probably why it is part of the LPIC cert test.
Plus, we all know the funny memes of people trying to get out of VIM “QX*JSWQiodjueiiu^Qeeemdnsnqqqq”
For work (ca. 600+ mixed Windows Server and Linux Servers, with 25% Windows, rest Linux) when I have to SSH into production servers, I am not supposed to install anything on those servers, just do the ticketed maintenance, thus VI it is.
But privately, man, this micro is the bee’s knees 🙂
Thanks Pete! Again, reading your blog made my day!
TextWrangler on Mac is the least awful text editor I’ve found on ‘mainstream ‘platforms. StrongEd on RISC OS is much better at almost everything.
But if you use a sensible system you don’t need a ‘text editor ‘ as a separate thing anyway.
Well, as I no longer use any Apple products inluding MACs, or RISC OS there is not much I can say about that, Tim – and I believe my systems are very sensible.
The key point is whether you are happy with what you use.
I refuse to use Windows because it makes me very unhappy. Mac, a bit less so. But as long as I can fire up Smalltalk on a machine I can get work done. Right now I’m having to do some work on an Ubuntu setup and it is not a pleasant UI experience at all.
We all have our preferences. Obviously, mine are well considered and arise from a careful and expert examination, whereas everyone that disagrees is acting purely on ridiculous emotions. 🤪
Of course, Tim, I do appreciate that you are right and the rest of us are all wrong. Even more strangely I was under the illusion that all of you are nothing more than a figment of my imagination – but of course I could be wrong 🙂 Sounds like we went to the same school of sarcasm.
Enjoy the MAC – you being there means I can ask you questions and will never have to touch one – it might contain harmful bacteria 🙂
Well we’re both grumpy ol’brits so I suspect we had the same teachers for compulsory sarcasm classes.
A smidge more seriously, editor and language choices seem to be something that is near religion. Very strange but that’s people for you.
Hi Peter, I too like Notepad++ and use it extensively on my PC. There is also a version for Linux(Ubuntu specifically I know of) that is very similar. I don’t know if it would work on Raspian (Debian).
I am going to try micro as it looks good. I’ll heed the sage advice from Antonio as I once tried Vi(m) (That’s a domestic cleaner isn’t it?), not an experience I’d care to repeat.
as a unix sysadmin, one needs to know at least the basics of VI, because as said it’s EVERYWHERE and often the only editor present… then, leave it there and install a better one 😀
VI and vim. My contribution to the religious wars.
I went through the learning cliff (more of an overhang) more years ago than I care to remember.
As mentioned by @DrFragle and MrShark, it is installed by default on just about every UNIX system and variants (including Linux and yes I know Linux is not UNIX). I have muscle memory now for vi and can accomplish just about anything any modern editor is capable of doing. Coupled with this is a deep knowledge of regex.
P.S. when asked, I do NOT recommend learning vi for beginners. It does take quite a bit of time to be comfortable and proficient. But like emacs, once learned, it is a very powerful editor.
Thanks for the great tip. Yeah, this tool looks much more capable than nano. The only thing I can’t figure out is how to make copy/paste work in Putty over SSH, not sure if it’s possible?
Hi there
Well, I stopped using Putty ages ago as I didn’t find it that user friendly – that’s when I stumbled across Mobaxterm for PC – which has both free and non-free versions, the latter simply allowing more open sessions at once. I use that exclusively now and have done for some time. Copy and paste definitely works in an SSH session from this MICRO editor without issue if that helps. Incidentally I also looked at KAAEDIT and NI – THE NICE EDITOR – but for me, MICRO stood out from the crowd as it immediately put me right in the centre of my Windows-centric comfort zone.
Don’t know if you are coming in from a Windows PC or something else – if the latter there are plenty of helpful resources and knowledgeable people out there, I’m not one of them. I’m more than happy with (variations of) of Debian on SBCs, but that’s my personal red line. When it comes to my PC I’m used to tools like Office, NotePad++ and other Windows-based tools hence my excitement at finally getting an editor for user PI that reminds me of Notepad++ – at least, that’s my experience after one day of experimenting with MICRO and getting better by the minute.
Thanks, Peter! Mobaxterm is a great Putty alternative, I’ll switch to it from now on 🙂
Good move Debra. It works well and handles SSH, Telnet, RSH, VNC, Serial, FTP, SFTP and a ton of other protocols – easy to use, reliable.
Regards
Pete.
AND don’t forget it has X11 forwarding automatically enabled… if you connect to a linux box which has a GUI, and you in moba run for example “firefox”, you get on your LOCAL pc the graphical interface of the REMOTE app, without any vnc, rdp or anything else: all you need is ssh access 🙂
Hi Debra, highlight with the mouse what you want to copy. Right click where you want to paste. I use Putty all the time (in mtputt – multitab putty).
Thanks Neil, sorry was not clear in my previous comment. I meant Putty copy/paste (including Ctrl-C/Ctrl-V) not working with Micro editor, general highlight/right-click works elsewhere 🙂
One word: Emacs, set it u (mu). Your Welcome. 😉 Let the religious wars begin.
Just kidding.
Morning Neil – Just for the sake of it, I looked up Emacs in the “Arcane Science Lab” this morning (early start) 🙂 and a quick apt-get install produced a whole ream of install messages followed by utter nothing – it would have installed around 300 MB had it not failed 🙂
leave it there… it’s an ancient, thought VERY powerful, editor, used for ages and for the same time in religious wars with VI(m) users 🙂
both are NO userfriendly AT ALL, but at least you have to learn some vi basics, as that’s the editor you’ll find in EVERY Unix out there 🙂
emacs… no, thanks, i used 20 years ago, time passed, new better stuff is out now 🙂
Pete, 300MB seems a little on the light side.
DrFragle and MrShark, you don’t know Emacs anymore (meant in a humorous way). It’s a lot easier to use today but it still has that huge learning curve.
Emacs is not a simple editor. Actually it probably should be called just an editor anymore. With it’s lisp libraries it can bend into what ever you want. I use it as my programming editor, IDE and note taking.
MrShark is correct about it being used for starting a religious wars. Usually it’s vi and Emacs but it now extends to other places. You’ll find Emacs keybindings for MS VC, Eclipse and others so you have the same keystrokes as Emacs. Unfortunately these IDEs don’t have the rest of Emacs making it difficult to switch. It a different way of thinking.
Right now I’m using it daily (Windows and Linux, same files) to take notes, organize and code like the Jupyter Notebook (can execute/compile code inside a document). I have images included (text links – file:///home/… ). I can even put Emacs lisp in the document and change the way the editor behaves. 🙂 I put a lot of bash scripts in my notes, execute them and keep the results in my notes. I keep lots of http links (calls my favorite browser) in my notes also. I like it better than MS Onenote (or VC or Eclipse). Oh, the file is still text so it can be read from text file readers and other editors. Emacs makes folding of the org-mode layout real easy.
Unfortunately, while C-c and C-v can be redefined, C-c is used in major mode (C-c C-c is used in many modes for many things, C-C and other keys do MANY other things). I have a ton of key bindings memorized (daily usage) but the cool thing is that my hands seldom leave the keyboard to do anything. I can use the mouse but in general there are keybindings that allow me to stay in the Emacs env. That I find extremely useful as I now need every second of the day and an unbroken concentration to keep pace with my present work env. We’ve gone to plaid!
I’ve also been using Emacs a long time (since 1978) and know the basic keystrokes by instinct. I have bash set -o Emacs for C-a/C-e/C-k. I’ve used these same keystrokes in Cisco routers and a few other devices. Oh Emacs behaves similarly on the Windows desktop, X and in a dumb terminal.
So if your looking for simple, that ain’t Emacs. If your looking for power, then I really doubt there’s anything more powerful than Emacs.
life is too short, and i’ve too many tv series to watch, still… and i watch’em at 1.33x speed! 😀
I agree but I can’t sit still long enough to really watch TV. Would love to have a speed on many more programs (1.5 here). I’ve gone to 2 on some of my training classes.
These two blokes are sitting at a bar.
One turns around to other and asks “What’s your IQ?”
“145” was the answer.
“Mine’s 143. What do you think of string theory and multiple universes?”
They then proceed to talk about life the universe and everything and become lifelong friends.
A little further down the bar, another patron heard this and turns to the bloke next to him and says:
“My IQ is 119, whats yours?”.
“120” is the response. They then go on to talk about engineering problems and ther solutions and become lifelong friends.
Further down the bar another customer turns to the one next to him and says:
“My IQ is 93 whats yours?”
“91” is the response. They start talking about sports and become lifelong friends.
Further down the bar, another customer turns to one next to him and says:
“My IQ is 50, whats yours?”
“Mine’s 50 as well. Do you prefer emacs or vi?”
I don’t get it. 😉