Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:32:03+00:00 2026-05-26T12:32:03+00:00

Just finished incorporating PHP_Beautifier into Vim and the fact that it removes whitespace irks

  • 0

Just finished incorporating PHP_Beautifier into Vim and the fact that it removes whitespace irks me. Apparently it’s a bug since 2007. There is a hack to fix this problem, but it leads to other problems. Instead I decided to use a round about method.

First Convert multiple blank lines to a single blank line via the command as suggested here

:g/^\_$\n\_^$/d

Next Convert all blank lines to something unique like so (make sure it does not get changed during beautification)

:%s/^[\ \t]*\n/$x = 'It puts the lotion on the skin';\r/ge

Next Call PHP_Beautifier like so

:% ! php_beautifier --filters "ArrayNested() IndentStyles(style=k&r) NewLines(before=if:switch:foreach:else:T_CLASS,after=T_COMMENT:function)"<CR>

Finally Change all unique lines back to empty lines like so

:%s/$x='It puts the lotion on the skin';//ge

All four work when I tested them independently. I also have the third step mapped to my F8 key like so

map <F8> :% ! php_beautifier --filters "ArrayNested() IndentStyles(style=k&r) NewLines(before=if:switch:foreach:else:T_CLASS,after=T_COMMENT:function)"<CR>

But when I try to string the commands together via the pipe symbol, like so (I padded the pipes with whitespace to better show the different commands)

map <F8> :g/^\_$\n\_^$/d    |    %s/^[\ \t]*\n/$x = 'It puts the lotion on the skin';\r/ge      |      % ! php_beautifier --filters "ArrayNested() IndentStyles(style=k&r) NewLines(before=if:switch:foreach:else:T_CLASS,after=T_COMMENT:function)"     |     %s/$x = 'It puts the lotion on the skin';//ge<CR>

I get the following error

Error detected while processing /home/xxx/.vimrc:
line  105:
E749: empty buffer

E482: Can't create file /tmp/vZ6LPjd/0
Press ENTER or type command to continue

How do I bind these multiple commands to a key, in this case F8.


Thanks to ib’s answer, I finally got this to work. If anyone is having this same problem, just copy this script into your .vimrc file

func! ParsePHP()
    :exe 'g/^\_$\n\_^$/d' 
    :%s/^[\ \t]*\n/$x = 'It puts the lotion on the skin';\r/ge
    :exe '%!php_beautifier --filters "ArrayNested() IndentStyles(style=k&r)"'
    :%s/$x = 'It puts the lotion on the skin';//ge 
endfunc

map <F8> :call ParsePHP()<CR>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:32:03+00:00Added an answer on May 26, 2026 at 12:32 pm

    For some Ex commands, including :global and :!, a bar symbol (|) is
    interpreted as a part of a command’s argument (see :help :bar for the full
    list). To chain two commands, the first of which allows a bar symbol in its
    arguments, use the :execute command.

    :exe 'g/^\_$\n\_^$/d' |
    \   %s/^[\ \t]*\n/$x = 'It puts the lotion on the skin';\r/ge |
    \   exe '%!php_beautifier --filters "ArrayNested() IndentStyles(style=k&r) NewLines(before=if:switch:foreach:else:T_CLASS,after=T_COMMENT:function)"' |
    \   %s/$x = 'It puts the lotion on the skin';//ge
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
I just finished a computer organization course, in which we learned that all files
I just finished watching Stefan Schackow's PDC 2009 session and he mentioned that he
I just finished writing a function that has ended up with nested code blocks
I just finished a little 5000-line PHP application and are now going into testing
I just finished my a Batch COLOR script that accepts Color-names, Decimals and Hex
I just finished programming a plattform on PHP that uses MySQL to save the
I just finished integrating the Facebook 3.1 API into our app, and have left
Just finished a little app that I want to distribute and at the moment
I have just finished incorporating a jQuery accordian with a jQuery Slider. I.e. 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.