You are not logged in.

#1 2024-11-27 10:58:26

MarkW
Member
Registered: 2024-11-03
Posts: 240

Do Any Text Editors/IDEs Have Automatic Formatting?

Whenever I copy/paste someone's bash code into a TE it ends up as one long line of text instead of several neatly formatted rows.

Offline

#2 2024-11-27 12:11:02

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

a. The cli tool I use from time to time is called shfmt (in repos).

shfmt -i 4 script > out

see

shfmt --help

b. VS Code should have a formatter plugin (not just one).

c. If such function does not exists in geany (I don't remember), one could do a custom command (pipe to shfmt), similar to the thing explained here
https://askubuntu.com/questions/481182/ … any-editor

Offline

#3 2024-11-27 14:54:20

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 827

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:

Whenever I copy/paste someone's bash code into a TE it ends up as one long line of text instead of several neatly formatted rows.

There are two ways to solve the problem:

1) Check how your text editor is set up.

I use Gedit and this is what the tab View looks like in Preferences:

gedit-preferences.png

Text Wrapping must be enabled if you don't want very long lines.

2) I don't know what text editor you're using, but the configuration file is probably somewhere in your HOME folder (maybe inside ~/.config).

If you close the text editor and delete the configuration file the next time you start TE, it should have the default settings.


If people would know how little brain is ruling the world, they would die of fear.

Offline

#4 2024-11-27 15:57:04

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

as an example, here's a simple bash script posted by Argantes

2024-11-27-15-33-48-scrot.png

and here's how it looks posted in geany with line wrapping

2024-11-27-15-43-16-scrot.png

Last edited by MarkW (2024-11-27 15:59:06)

Offline

#5 2024-11-27 21:59:37

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

Check these preferences in Geany.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#6 2024-11-27 23:13:11

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:

as an example, here's a simple bash script posted by Argantes

https://i.postimg.cc/87CgFQ36/2024-11-27-15-33-48-scrot.png

and here's how it looks posted in geany with line wrapping

https://i.postimg.cc/nM7FZxbV/2024-11-27-15-43-16-scrot.png

You have a link for the original script?


You must unlearn what you have learned.
    -- yoda

Offline

#7 2024-11-27 23:24:06

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

It's in this thread

Offline

#8 2024-11-28 02:42:42

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:

It's in this thread

I didn't have any formatting issues doing a copy/paste with any of those scripts in either geany or sublime editors.

You can try those settings recommended by Sector11 and marens, but if the geany.conf file is corrupted, this may be your best bet:

If you close the text editor and delete the configuration file the next time you start TE, it should have the default settings.

You must unlearn what you have learned.
    -- yoda

Offline

#9 2024-11-28 06:53:59

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,549
Website

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

Does the issue turn up only in geany? Try pasting into a different text editor.
It looks as if all the linebreaks are being stripped out somewhere - that's not something that a text editor being used for programming would usually do.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

#10 2024-11-28 10:50:28

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

L3afpad

rZJP8mTt.png

Gedit

ULHTRNBt.png

Mousepad

YYSfUUst.png

Offline

#11 2024-11-28 10:57:33

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

PackRat wrote:
MarkW wrote:

It's in this thread

I didn't have any formatting issues doing a copy/paste with any of those scripts in either geany or sublime editors.

You can try those settings recommended by Sector11 and marens, but if the geany.conf file is corrupted, this may be your best bet:

If you close the text editor and delete the configuration file the next time you start TE, it should have the default settings.

Did that, same result

Offline

#12 2024-11-28 13:47:09

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:
PackRat wrote:
MarkW wrote:

It's in this thread

I didn't have any formatting issues doing a copy/paste with any of those scripts in either geany or sublime editors.

You can try those settings recommended by Sector11 and marens, but if the geany.conf file is corrupted, this may be your best bet:

If you close the text editor and delete the configuration file the next time you start TE, it should have the default settings.

Did that, same result

If you open a man page in a terminal is it properly formatted?

You can try this in a terminal:

man tar | col -b > tar_man.txt

That will generate a text file of the tar man page. Open that text file and see if the formatting is preserved.

You may be having an issue with the locale ( https://www.debian.org/doc/manuals/debi … the_locale )


You must unlearn what you have learned.
    -- yoda

Offline

#13 2024-11-28 13:51:44

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

A man page for geany?  I guess, if this is what it's supposed to look like

tHhngZft.png

Offline

#14 2024-11-28 16:57:11

novice
Member
Registered: 2020-01-30
Posts: 61

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

That's obviously working. Have you tried pasting the code into the terminal to see if that works?

Offline

#15 2024-11-28 17:22:58

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

Looks the same in a terminal as it does in a text editor.

Offline

#16 2024-11-28 17:26:24

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:

A man page for geany?  I guess, if this is what it's supposed to look like

https://i.imgur.com/tHhngZft.png

That looks right.


You must unlearn what you have learned.
    -- yoda

Offline

#17 2024-11-28 18:00:01

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

My locale is set to en-GB.  Which is correct for me.  Should I add more?

uVqHrx8t.png

Offline

#18 2024-11-28 19:10:24

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 2,611

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

MarkW wrote:

My locale is set to en-GB.  Which is correct for me.  Should I add more?

https://i.imgur.com/uVqHrx8t.png

No, you're good there.


You must unlearn what you have learned.
    -- yoda

Offline

#19 2024-11-29 01:52:26

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,549
Website

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

It looks as if there's something wrong about the way you're copy/pasting code from the web.
Can you copy/paste from a local file with linebreaks intact?
Maybe a problem with your browser?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

#20 2024-11-29 10:47:37

MarkW
Member
Registered: 2024-11-03
Posts: 240

Re: Do Any Text Editors/IDEs Have Automatic Formatting?

I tried with a local file.  It's the copy/pasting

Would an improperly formatted script still work?

Offline

Board footer

Powered by FluxBB