ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 .
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.
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
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.
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
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!
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.