Editor that workswith standard Mac movement commands in terminal?

By Khomus, 24 October, 2024

Forum
macOS and Mac Apps

Hi, I'm back again!

Is there an editor in terminal that works with standard movement commands? In pico I can move by lines with the arrows, and by character, but option left and right don't work to move by word, so it makes editing pretty tedious. I can't use something like text edit, because it's being called from another program. So it has to be more unix-like, if that makes sense. By default it was calling vim. I've never messed with it much,but I could try and learn it if that one works.

Options

Comments

By João Santos on Friday, October 25, 2024 - 00:11

What you are asking for doesn't really exist as far as I know, and might never come to existence in the future.

The first problem are the modifier keys. in standard terminals in canonical mode, the Control key sends control signals when combined with other keys, the Alternative key, or Option key as it was traditionally named on Mac keyboards, sends Meta ANSI escape sequences when combined with other keys. And lastly there's the Apple / Command / Globe or Windows key on Macs and IBM PC computer clones, also known as the Super key, which to my knowledge doesn't really do anything in standard terminals since historically it hasn't always existed.

The second problem is that standard console terminals are just matrices of monospaced colored characters with zero semantic information for screen-readers, making all kinds of text-based visual user interfaces somewhat annoying to people who can't actually see the screen. In theory, screen-readers could try to heuristically understand that kind of output and provide their own semantic navigation over it, but that would be a form of over-engineering with very little return considering that in most cases there is always a better way to work around these problems.

The best example of a problem I can think of that is simply impossible for a console text editor to tackle due to the issues that I mentioned above is copy-pasting to a different application. Copying text through the terminal boundary is impossible, so whenever you wish to copy text from a console editor to another application, the only way you can do it is by selecting text on the terminal itself, which among other things has the problem of not carrying semantic information, so what you end up copying is the portion of the character matrix that displays the text, which may include extra new line characters for text wrapping or expanded tab characters in the form of spaces. Another problem with copy-pasting from terminals, on Windows specifically, is that for some reason Microsoft decided to map Control+C to copy from Windows 95 onwards, which collides directly with the standard meaning of the Control+C keyboard interrupt signal in standard terminals with canonical mode enabled.

The above problems combined make providing decent accessibility or a native control experience in a console text editor very hard if not impossible to implement. However this isn't really an issue since many code-oriented text editors can easily and fully replace their console counterparts quite easily. TextMate is one such editor for MacOS; it has a glaring missing feature which is the ability to serve as a client to Language Server Protocol implementations that provide quality of life features such as code completion, inline documentation, jump to definition, among others, but on the other hand it provides command-line utilities that make it possible for you to open both local and remote files almost seamlessly, and even pipe the output of console commands to it, as if you were using a console editor, but with the advantage of semantic navigation provided by native controls.

As for Vim, its interface is nowhere close to what most people expect from a text editor these days. It is designed to be used exclusively with the keyboard, and I used to love it back in my sighted days, but it does have a steep learning curve that has been a source of criticism even by many other season software developers. Another classic keyboard-first editor is Emacs, which suffers from the same steep learning curve as vim, but benefits from a much richer ecosystem of third-party packages which I believe result from its reliance on a dialect of Lisp, a highly dynamic expression-based standardized family of languages that is either pretty interesting or pretty useless depending on whether you lean more towards the scientific or engineering components of software development respectively.

While both vanilla Vim and Emacs can be used by masochist blind users on the console, to my knowledge the only real option for us right now is Emacs with an accessibility modification called EmacSpeak, which kinda turns Emacs into a fully blown desktop environment complete with its own screen-reader. Back in the day there used to be a running joke about Emacs being a good operating system that was just missing a decent text editor so they added a Vi mode, which I think is actually pretty accurate, and as a result of that, EmacSpeak pulls a lot of dependencies on MacOS that I don't really like to clutter my system with so I don't use it myself.

By Ollie on Friday, October 25, 2024 - 00:11

Might be worth trying nano. I don't think it's much better and has it's own issues but may work better.

By Top Shelf on Friday, October 25, 2024 - 00:11

FWIW, I use joe. Good old fashion WordStar command set.

By Khomus on Friday, October 25, 2024 - 00:11

Sorry, I should have been clearer. I just need something that has a
command that let's you move by words, Pico doesn't seem to have that,
I'm guessing Nano doesn't either. I would have thought that if opt-left/right didn't work, then ctrl-left/right would, but of course, that switches desktops, if you have any.

Also, while we're at it, how *do* you select text in a terminal window?Can you? I don't care about monotonous colors or lack of formatting,I just want the text. I can fix it later, if that's something I feel is really necessary. I'm thinking of stuff like, I have an error, and I want to copy and paste that text to post it somewhere to get help. Or suppose I'm in terminal, and I get output, and I want to copy that output and paste it into an editor like Nano?

By PaulMartz on Friday, October 25, 2024 - 00:11

Issue the following command in Terminal.

open -a TextEdit

That's the word open in all lower case, a space, then a hyphen and lowercase A, another space, then the word TextEdit with camelcase T and E.

If you want to open a specific file, append a space and the filename.

This should work from either a script or interactive shell.

I hope this helps.

By PaulMartz on Friday, October 25, 2024 - 00:11

I'll add that I have nothing against vi or vim, or even emacs for that matter. Back when I was cutting my teeth on Unix, they all got the job done, even ed and sed.

And I do believe you can move by word in vi and vim. There's also a method to copy and paste. But unless you use these editors every day, and I don't, the commands become nearly impossible to recall.

But if you need to launch an interactive editor, and you already know TextEdit, then you should just launch TextEdit.

By Top Shelf on Friday, October 25, 2024 - 00:11

Khomus, Joe normally isn't installed by default and while it works OK out of the box, customization of the .joerc file can help depending on the commands you desire. But, as Paul said, give TextEdit a go. Personally I normally access all of my Linux boxes via Windows/JAWS/ssh so I usually achieve copy/paste tasks by creating a virtualizing the ssh window and selecting text that way.
Do let us know what ends up working.

By Khomus on Saturday, October 26, 2024 - 00:11

I'm running a BBS client, specifically for ISCA BBS.

https://iscabbs.rocks/

It runs in terminal. The guy who did it said he did minimal work on it and for him, it crashes if he tries to open an editor. I just made it open one without even setting any, and it opened Vim. Then I told it to use Nano, and it must be aliased, because it gives me Pico.

When you hit ctrl-x in Pico after editing, it asks you if you want to save. It wants to save in a specific file, which the client deletes after you post, or saves in case something gets messed up if you didn't. Anyway, I'm not sure the client will take an entire shell command, although I guess I could try it. I could also learn the super basic Vim commands and try using that too. Thanks everybody!

By Khomus on Saturday, October 26, 2024 - 00:11

TextEdit actually works like a charm, thanks for the suggestion!

In case anybody else ends up trying it, you have to add an extra blank line at the end so the last word of your post doesn't get cut off.