appending spaces to EOL

Anonymous
2012-05-10
2012-11-14
  • Anonymous - 2012-05-10

    I have a non-standard request. I would like to do two types of thing from within NPP:
    (1) Append several hundred spaces to the EOL of each line;
    (2) Use a printf(…)-like command to pad the left or right side of each line with as many spaces as needed to bring all lines to the same specified width.

    Because of the large number of spaces I would like to append to the EOL, a simple regex replace with manual insertion of spaces doesn't seem workable. What options are available to me?

    Eric

     
  • JimD

    JimD - 2012-05-16

    Here's an AWK one-liner that does what you're asking:

    ( ) C:\> type test.txt                                                 
    123456 890                                                                       
    123                                                                              
    12345                                                                            
    1 3 5 7 9                                                                        
    1                                                                                
                                                                                     
                                                                                     
    ( ) C:\> gawk "{printf(\"'%s%*c'\n\",$0,30-length($0),\" \")}" test.txt
    '123456 890                    '                                                 
    '123                           '                                                 
    '12345                         '                                                 
    '1 3 5 7 9                     '                                                 
    '1                             '                                                 
    '                              '