GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - beanworks/vim-phpfmt: PHP (phpcbf) auto format plugin for vim

BranchesTags
Open more actions menu

Latest commit

 

History

15 Commits
15 Commits

Folders and files

NameName
Last commit message
Last commit date
autoload/phpfmt
autoload/phpfmt
 
 
doc
doc
 
 
plugin
plugin
 
 
third_party
third_party
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

vim-phpfmt

PHP auto format plugin for vim. It works seamlessly with phpcbf, and automatically formats currently editing PHP file on save, or by manually running command :PhpFmt.

Install

Vim-phpfmt follows the standard runtime path structure, so we highly recommend to use a common and well known plugin manager to install vim-phpfmt. For Pathogen just clone the repo. For other plugin managers add the appropriate lines and execute the plugin's install command.

  • Pathogen: git clone https://github.com/beanworks/vim-phpfmt.git ~/.vim/bundle/vim-phpfmt
  • vim-plug: Plug 'beanworks/vim-phpfmt'
  • NeoBundle: NeoBundle 'beanworks/vim-phpfmt'
  • Vundle: Plugin 'beanworks/vim-phpfmt'

Settings

By default third_party/phpcbf.phar is used to format PHP code with PSR2 as the default standard. To change to a different standard type or file, add the following setting to your vimrc file:

" A standard type: PEAR, PHPCS, PSR1, PSR2, Squiz and Zend
let g:phpfmt_standard = 'PSR2'

" Or your own defined source of standard (absolute or relative path):
let g:phpfmt_standard = '/path/to/custom/standard.xml'

Vim-phpfmt will first writes buffer to a temp file in the temp folder configured, then runs phpcbf over the temp file, and then copies formatted content back to the editing view, and restores cursor position.

Auto format on save is enabled by default, to disable it:

let g:phpfmt_autosave = 0

For more precise control, you can specify paths to your own phpcbf executable, or another PHP formatter of your choice. You can also set up a different temp file storing folder for intermediate formatting buffer:

let g:phpfmt_command = '/path/to/phpcbf'
let g:phpfmt_tmp_dir = '/path/to/tmp/folder'

Usage

Once the settings are in place, invoke command :PhpFmt to call the formatter. If auto format is enabled by setting :w or :x will automatically triggers the formatter.

Working with Docker

If you are using docker for dev, and having phpcbf executable installed inside the container, along with your own standard source. You can still use vim-phpfmt.

Assume you have mounted source code folders as volumes to the container, you can then change the settings to:

" NOTE: all the paths below should be pointing to executable, standard file,
"       and tmp folder that are actually inside the container
let g:phpfmt_command = 'docker exec container_name /path/to/phpcbf'
let g:phpfmt_options = '--standard=/path/to/custom/standard.xml --encoding=utf-8'
let g:phpfmt_tmp_dir = '/path/to/tmp/folder'

About

PHP (phpcbf) auto format plugin for vim

github.com/beanworks/vim-phpfmt

Resources

Readme
MIT license
Activity
Custom properties

Stars

44 stars

Watchers

6 watching

Forks

14 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.