LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2019, 05:06 PM   #1
AnneRanch
Member
 
Registered: Oct 2018
Posts: 198

Rep: Reputation: 12
nano editor formatter ?


In C/C++ IDE - likes Eclipse - there is a way to "format / beautify" source text.
The "formatter" plug-in is very common, however its name escapes me.
Something about "art...".

My 15000 lines plus script is getting little cluttered and it would be nice if I could re/format it.
Since bash formatting convention are different than C I am reluctant to import the text into IDE and format it there.

I did search for "bash / nano formatter" but did not find any.

Any hint as where to look or how accomplish the text file (bash) formatting would be appreciated .
 
Old 04-06-2019, 07:09 PM   #2
freemedia2018
Member
 
Registered: Mar 2019
Distribution: various automated remasters
Posts: 216

Rep: Reputation: 208Reputation: 208Reputation: 208
Do you mean syntax highlighting in nano? https://how-to.fandom.com/wiki/How_t...no_text_editor

I don't think nano has a syntax-based autoformatting feature.

Bash autoformatting: https://unix.stackexchange.com/quest...t-shell-script
 
Old 04-06-2019, 09:44 PM   #3
AnneRanch
Member
 
Registered: Oct 2018
Posts: 198

Original Poster
Rep: Reputation: 12
Quote:
Originally Posted by freemedia2018 View Post
Do you mean syntax highlighting in nano? https://how-to.fandom.com/wiki/How_t...no_text_editor

I don't think nano has a syntax-based autoformatting feature.

Bash autoformatting: https://unix.stackexchange.com/quest...t-shell-script
Syntax highlighting is already set in nanorc.
Since I was not sure if nano has formatter, I asked here.
I'll keep looking.
 
Old 04-06-2019, 10:00 PM   #4
freemedia2018
Member
 
Registered: Mar 2019
Distribution: various automated remasters
Posts: 216

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by AnneRanch View Post
Since I was not sure if nano has formatter, I asked here.
Oh it was a perfectly reasonable question on your part. I joined you on what I think is a wild goose chase, and I'm only calling it one to hopefully save you too much trouble.

Fellow nano fan, I would have loved to have found such a feature. Good luck.
 
1 members found this post helpful.
Old 04-06-2019, 10:09 PM   #5
AnneRanch
Member
 
Registered: Oct 2018
Posts: 198

Original Poster
Rep: Reputation: 12
I hate forums,
My last post went nowhere.
nano has "Justify entire file" which does the job of formatting.
"Atl M" on keyboard.
 
Old 04-07-2019, 09:21 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by AnneRanch Post #1
In C/C++ IDE - likes Eclipse - there is a way to "format / beautify" source text.
The "formatter" plug-in is very common, however its name escapes me.
Something about "art...".

My 15000 lines plus script is getting little cluttered and it would be nice if I could re/format it.
Since bash formatting convention are different than C I am reluctant to import the text into IDE and format it there.

I did search for "bash / nano formatter" but did not find any.

Any hint as where to look or how accomplish the text file (bash) formatting would be appreciated .
Quote:
Originally Posted by AnneRanch View Post
I hate forums,
You are free to not come back; you know that, right?
Quote:
My last post went nowhere.
The responses typically match the questions....poor questions with no effort usually get poor responses.
Quote:
nano has "Justify entire file" which does the job of formatting.
"Atl M" on keyboard.
...and "Justify entire file" is **NOT** 'formatting' the code. There are an abundance of IDE's like Anjuta, Kdevelop, etc., that actually DO code highlighting. If all you want is justified text, open it with any text editor and do it, or run it through SED.

Last edited by TB0ne; 04-07-2019 at 02:33 PM.
 
2 members found this post helpful.
Old 04-07-2019, 05:34 PM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,276
Blog Entries: 24

Rep: Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224
I realize that you asked about a shell script formatter for nano, so not being a nano user I cannot offer useful help with that.

However, being a Vi/Vim user and knowing how easy it is to format most common language syntaxes with it, I would suggest you might give it a try. If you use it for ntohing else but periodic reformatting of your code edited in nano, it would provide a quick solution which would not require any extra packages on nearly any distro.

For a quick intro to Vi/Vim, simply type vimtutor in a shell.

If you have a shell script you want to format, do the following to open, format then save your formatted file:

Code:
vim myfile.sh
:set syntax=shell <ENTER>
gg=G
ZZ
Then open your file in nano and it will have been formatted. There are also ways to use this as an in-place formatter with suitable options if interested. As always, explore the vim man pages.

Quote:
Originally Posted by AnneRanch View Post
I hate forums,
My last post went nowhere.
.
Perhpas you should give LQ a chance! I have no way of knowing what connotations "forums" carries for you, but perhaps you should try thinking of it differently. Rather than interacting with "a forum", realize that you are speaking with other human beings, albeit via typed text rather than vocally. Approach others here as if you were speaking directly to other persons, with due allowance for lack of facial expressions. Give some respect, get some respect and make some friends!

The universe is wired such that you ultimately receive as you give, so try a more positive approach and see if it doesn't return to you greatly amplified!

Good luck!
 
1 members found this post helpful.
Old 04-08-2019, 12:15 AM   #8
AnneRanch
Member
 
Registered: Oct 2018
Posts: 198

Original Poster
Rep: Reputation: 12
Thanks for the reference to vi , I'll give it try.
As fas as my remark about the forum - I wrote nice reply and it did post it. I was pretty ticked off.

You give a fair advise, unfortunately it would not make any difference how I reply to it.
This is not a fair open discussion forum and I prefer not to get banned from it.
Sorry.
 
Old 04-08-2019, 07:07 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,788

Rep: Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001Reputation: 8001
Quote:
Originally Posted by AnneRanch View Post
Thanks for the reference to vi , I'll give it try.
As fas as my remark about the forum - I wrote nice reply and it did post it. I was pretty ticked off.
It appears you were 'ticked off' at someone giving you an answer, and trying to engage you in conversation about what you were looking for.
Quote:
You give a fair advise, unfortunately it would not make any difference how I reply to it.
This is not a fair open discussion forum and I prefer not to get banned from it.
Sorry.
When you post things like you've done (https://www.linuxquestions.org/quest...0/#post5975538), do not be surprised if people don't want to help you. You don't appear to ever want to answer questions when asked, and get rude when someone gives you references for you to look at. Since you 'hate forums', and think that this is not a 'fair open discussion forum', I will again remind you that you are free to not come back.
 
2 members found this post helpful.
Old 02-24-2021, 01:01 AM   #10
tpoacher
LQ Newbie
 
Registered: Feb 2021
Posts: 1

Rep: Reputation: Disabled
Yes it does.

It depends on what you mean exactly, since nano does not come pre-loaded with the ability to format every single language known to man per se, but nano does indeed include support for external formatters.

See here: https://nano-editor.org/manual.html (search for the word "formatter" on that page).

Effectively you can define .nanorc files containing syntax highlighting instructions and other stuff for each language of interest, and this can include the name of a bash program that can be called to format the file (or a selection). However, while nano comes preloaded with nanorc files defining syntax for several languages, very few of these seem to name an explicit formatter assigned 'out-of-the-box' (at the point of writing this, I spot "go" and "html" assigning "gofmt" and "tidy" as formatters respectively).

But there's nothing stopping you from assigning yapf3 to python.nanorc yourself, for instance.
 
Old 02-24-2021, 05:03 AM   #11
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,686

Rep: Reputation: Disabled
The OP asked about shell formatter. One I know of is indent.awk from http://www.bolthole.com/AWK.html which also comes with UniversalIndentGUI.

Another option is writing a style file for EditorConfig.

Last edited by shruggy; 02-24-2021 at 10:04 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] A problem about java.util.Formatter cassati Programming 5 12-25-2010 05:09 AM
LXer: A New, Easy To Use Disk Formatter For GNOME LXer Syndicated Linux News 0 01-10-2009 03:10 AM
LXer: A New, Easy To Use Disk Formatter For GNOME LXer Syndicated Linux News 0 01-08-2009 07:20 PM
FF2 disable RSS formatter senyahnoj Linux - Software 0 03-05-2007 06:02 AM
Using floppy formatter causes system to hang. frf1218 Linux - Hardware 2 03-26-2004 04:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration