I have a file which is encoded by base64:

5byg5bCP5piO
c2FyYWg=
5p2O56OK

I want to decode it line by line:

:%!base64 -d

But I get everything in one line:

张小明sarah李磊

What I want is:

张小明
sarah
李磊

How can I do it?

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

Another solution is the following, which works nicely for me.

%g/^/.!base64 -d
link|improve this answer
1  
:g/./.!base64 -d – kev Dec 19 '11 at 7:07
vimgolfist? ;-) Yeah, the % is in case of :g redundant. Also the . regexp makes sense - no use to try to decode empty lines. – Martian Dec 19 '11 at 12:36
feedback
:%normal !!base64 -d^M

:{range}norm[al][!] {commands}                          *:normal-range*
                        Execute Normal mode commands {commands} for each line
                        in the {range}.  Before executing the {commands}, the
                        cursor is positioned in the first column of the range,
                        for each line.  Otherwise it's the same as the
                        ":normal" command without a range.
                        {not in Vi}
                        Not available when |+ex_extra| feature was disabled at
                        compile time.
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.