Search code examples
awkcommand-linesedtext-alignmentgeany

line too long error with columns


I'm trying to align text vertically with a delimiter in Geany text editor:

idxMathExpress (MathArcCos _) = 120
idxMathExpress (MathArcSin _)   = 130
idxMathExpress (MathArcTan _)     = 140

I would like this block to be aligned like this

idxMathExpress (MathArcCos _)  = 120
idxMathExpress (MathArcSin _)  = 130
idxMathExpress (MathArcTan _)  = 140

I tried to pass the selected text to an external command :

column -t -s '=' 

to make the job.

But when I launch the command, I get the following message

column : line too long

and I don't understand why.

Do you what is the problem whith this command ?

Do you know another way to align text with a separator with geany (awk, sed ...) ?


Solution

  • column requires every line to end with a new-line, if the input ends without a new-line column will produce the line too long error observed. To select the final new-line, with the 'Geany' editor, the selection must extend to the beginning of the next line.


    Using awk, and its printf, to align text (as in your example).

    awk -F' *=' '{printf"%s% 7s%s",$1,"="$2,RS}'