User avatar
GavinW
Posts: 99
Joined: Tue Nov 01, 2011 8:11 pm
Location: UK
Contact: Website

Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 1:42 pm

I am looking for a linux text editor which lets me apply a command to the contents of a buffer/window and puts the resulting output into another buffer/window. Among the huge variety of text editors there must surely be some that can do this.
otium negare negotium vanum

Linux User
Posts: 3
Joined: Fri Aug 07, 2020 5:25 pm

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 2:14 pm

there are in my mind only a way by:
creating a shell script (example edit.sh)
Or you combine the syntax "in" the Shell Script to give it to the Programm.

There are different options for eatch programm.
maybe you have good luck and you can give that, what you want,
at the Programmstart to the Programm.
Sorry for my bad english. Hope it is helpfully
And answer is in the right way to your Ask.

Linux User
Posts: 3
Joined: Fri Aug 07, 2020 5:25 pm

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 2:22 pm

maybe you can use an comand that looks how "cat" for the reading. But im not sure it works in your
"Window" and too for the output it seams not be the wrigt command. But i think there can be a way.
With python script or an alternative language.

Sorry more i cant help

trejan
Posts: 2237
Joined: Tue Jul 02, 2019 2:28 pm

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 2:26 pm

Emacs can do it but that isn't surprising considering the everything including the kitchen sink nature of it.

See https://www.emacswiki.org/emacs/ExecuteExternalCommand

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 2:58 pm

I am looking for a linux text editor which lets me apply a command to the contents of a buffer/window and puts the resulting output into another buffer/window. Among the huge variety of text editors there must surely be some that can do this.
Can you give an example of what you want to achieve?

In vi or Vim you can include the output of an external command in the current editor buffer:

Code: Select all

<ESC>!!ls -l
And you can run an external command but not save the output in the editor buffer:

Code: Select all

<ESC>:!ls -l
I expect emacs is better, I just never learned it! :)

User avatar
GavinW
Posts: 99
Joined: Tue Nov 01, 2011 8:11 pm
Location: UK
Contact: Website

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 4:10 pm

Thanks for the advice. I would like to be able to reproduce in Raspbian (or Manjaro) what I can do with the editor StrongED in RISC OS, namely apply a script (typically Awk or Lua) to the contents of a StrongED window by dragging the script-file's icon into the window. SHIFT-drag replaces the window's contents by the output, CTRL-drag puts the output into a new window. In the script arg[1] can be taken to be the pathname of a virtual file containig the window's text. This is a very useful general tool, which can often replace more specialized functions that are built in, such as search-and-replace. I will see if Emacs can be coaxed into doing this; I had been hoping that something smaller would offer this facility.
otium negare negotium vanum

User avatar
scruss
Posts: 3256
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 4:20 pm

emacs, as trejan noted. The simplest built-in way is to select all, then Meta-|, then type your command. This will put your output in a new temporary buffer called *Shell Command Output*. Note that any subsequent output overwrites this buffer, so save it if you need it.

There are myriad options and many packages to modify or improve how this works.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

theodore_dream
Posts: 3
Joined: Wed Jul 15, 2020 2:46 am

Re: Is there a Linux text editor that can ... ?

Sat Aug 08, 2020 7:28 pm

Hello! I think that having a more specific example of what you mean in terms of buffering might help .... I think what you might be looking for would be shell redirection?

This would be an example of shell redirection, taking output from the terminal and redirecting it into a file

# ls -la > list.txt

This would take the output of "la -la" and put it into a text file named "list.txt" - however this overwrites anything that was in the file previously

If you want to only _add_ content and not overwrite any content in the file, you can do:

# ls -la >> list.txt

Maybe that's helpful? :?

Looking at your most recent post it seems you want something GUI based for moving around text data, I would strongly reccomend against trying to use GUI methods for this type of thing, in general Linux has much better functionality on cli instead of GUI. Even if you can make it work on GUI, if you hit an issue might be a nightmare to troubleshoot, cli is generally easier for documentation and debugging.

Maybe doing something like taking one file and pushing it to another file, might be relevant?

# cat file1.txt >> final.txt

Then if you need to replace certain output in the file text, or make specific changes to certain parts of the file, you can use "sed" command


Best of luck!

User avatar
GavinW
Posts: 99
Joined: Tue Nov 01, 2011 8:11 pm
Location: UK
Contact: Website

Re: Is there a Linux text editor that can ... ?

Tue Aug 11, 2020 9:33 am

Thanks. I am sure you are right in your observations about CLI v GUI. At the risk of abusing Forum protocol, I would like to enquire whether anybody can point me in the direction of literature about the principles of GUIs. Am I right to suggest that the popularity of Linux has only risen with the emergence of GUIs - which of necessity are tacked on as an afterthought rather than designed in ab initio? It seems to me that remarkably little progress has been made in the development of GUIs over the last 40 years. Being clumsy fingered and forgetful I judge the convenience of a system by how infrequently I must resort to using the keyboard: apart from entering passwords or (re)naming things I would like to be able to ignore the keyboard altogether. Of course, underlying any operating system there should be a textual CLI. The important aspect of a GUI is the establishment of a consistent visual metaphor and the provision of user-definable bindings between user-actions and CLI combinators, subject to convenient protocols on the visual representations of types, the current state of processes, etc. In short, I am looking for some thinking about user-interaction in general.
otium negare negotium vanum

User avatar
PeterO
Posts: 5951
Joined: Sun Jul 22, 2012 4:14 pm

Re: Is there a Linux text editor that can ... ?

Tue Aug 11, 2020 9:42 am

GavinW wrote:
Tue Aug 11, 2020 9:33 am
Am I right to suggest that the popularity of Linux has only risen with the emergence of GUIs - which of necessity are tacked on as an afterthought rather than designed in ab initio?
Depends on what you mean by "popular" and what you consider to be the "popular audience".
But Linux has had X windows pretty much from the start, and Unix had it before that. Here's some of the history
https://en.wikipedia.org/wiki/X_Window_System#History

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jahboater
Posts: 5825
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Is there a Linux text editor that can ... ?

Tue Aug 11, 2020 10:34 am

PeterO wrote:
Tue Aug 11, 2020 9:42 am
GavinW wrote:
Tue Aug 11, 2020 9:33 am
Am I right to suggest that the popularity of Linux has only risen with the emergence of GUIs - which of necessity are tacked on as an afterthought rather than designed in ab initio?
Depends on what you mean by "popular" and what you consider to be the "popular audience".
But Linux has had X windows pretty much from the start, and Unix had it before that. Here's some of the history
https://en.wikipedia.org/wiki/X_Window_System#History
Linux and UNIX are totally dominant in the server market, few of which would ever run a GUI.
At the other end of the scale Linux is popular running embedded on small devices, again mostly without a GUI.
Pi4 8GB running PIOS64

bjtheone
Posts: 883
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: Is there a Linux text editor that can ... ?

Tue Aug 11, 2020 3:03 pm

Further to Peter's point Linux has had X from the beginning, whereas Windows evolved out of Dos. You could make the rather tortured argument that Linux is more GUI based that Windows.

Personally I think the bigger win with Linux is that you can comfortably live in the GUI if you want, and yet still have easy access to a very powerful command line environment. Windows is getting better recently but I would still give the win cli wise to Linux.

The one thing that Linux is lacking is the central control that provides consistency across all applications. This is where MacOS shines. Of course the downside to centralized control is that many folks don't particularly like being locking into one design metaphor.

Return to “Beginners”