LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-02-2023, 03:50 AM   #1
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,307

Rep: Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021
Tip: adjust indention in text files


I have two executable sed scripts at a location that is in my PATH
Code:
$ cat indent+
#!/usr/bin/sed -f
# Doubles the number of leading spaces
s/^ */&&/

$ cat indent-
#!/usr/bin/sed -f
# Halves the number of leading spaces
s/^\( *\)\1/\1/
If I want to double or halve the number of leading spaces on my test.awk file then I run
Code:
indent+ test.awk
indent- test.awk
and redirect the output to a new file.

If you use tab characters then first replace them with spaces, by using the expand command.
Example
Code:
expand test.awk | indent- > newtest.awk
 
Old 03-02-2023, 04:49 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 19,880

Rep: Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734
Sorry, I don't really understand. Every editor has features to [un]indent.
 
Old 03-02-2023, 05:46 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,307

Original Poster
Rep: Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021Reputation: 1021
Perhaps I am the only one. Had worked on some deeply nested customer scripts that were 8 characters (or one tab) per indention.
My screen was not wide enough, or the text size became too small.
So I used these utilities to shrink them to my screen size, and after work grow them to the size the customer wanted.
 
1 members found this post helpful.
Old 03-02-2023, 05:50 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,751

Rep: Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972
Quote:
Originally Posted by MadeInGermany View Post
Perhaps I am the only one.
Perhaps not. I like it - much better than bc ...
 
Old 03-02-2023, 08:56 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 19,880

Rep: Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734
I downloaded a tool for shell (shfmt) to do full formatting, another one for python and groovy. They called code beautifiers and do much more, not only correct indentations.
 
Old 03-02-2023, 09:12 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,974

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
I set my tab settings in vim and use tabs command in bashrc to set command line indenting
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
bad indention whencopy from internet documentation into vim yaml file Alexmicu Linux - General 2 05-02-2022 11:43 PM
[SOLVED] Adjust desktop icon text in KDE fixer1234 SUSE / openSUSE 3 10-10-2018 08:42 PM
Can't adjust brightness with function key and can't adjust brightness after suspend. QuarkDev Linux Deepin 2 03-19-2015 10:46 AM
need shell command to wrap text &adjust column width (csv file ) Sankaran29 Linux - Newbie 6 12-17-2012 09:33 AM
LXer: Tip: Tip: Simple Regular Expressions For Reviewing Log Files LXer Syndicated Linux News 0 11-20-2008 12:41 PM

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

All times are GMT -5. The time now is 06:39 AM.

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