Vim (for Vi Improved) is a screen-oriented text editor originally created for the Unix operating system. This guide install some helpful plugins for PHP development.
This howto is tested on:
- Debian 10.0 Buster
Requirements
This howto requires:
- A working Vim installation, as described by Install Vim on Debian.
Installation
Detect if sudo is available (“command” is used if not):
cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'
Install the required software:
${cmdProxy} apt install 'unzip'
A graphical user interface for Vim exists: gvim, using the GTK toolkit. Install it with:
${cmdProxy} apt install 'vim-gtk3'
A modern alternative to Vim exists: NeoVim a.k.a. nvim. Install it with
${cmdProxy} apt install 'neovim-qt'
Configuration
PDV : phpDocumentor for Vim
PDV is a tool generating automatically the code documentation of a PHP script. Install PDV:
command mkdir -p "${HOME}/.vim"
command wget "http://www.vim.org/scripts/download_script.php?src_id=4666" \
--output-document="${HOME}/.vim/php-doc.vim"
command echo '
" PDV : phpDocumentor for Vim
" http://www.vim.org/scripts/script.php?script_id=1355
source ~/.vim/php-doc.vim
inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocRange()<CR>' \
>> "${HOME}/.vimrc"
This tool is used by pressing <Ctrl>+ <P> when the cursor is on a class, function, constant, etc. declaration.
Vimball
Vimball is a helper easing development of Vim extensions. Install Vimball:
command mkdir -p "${HOME}/.vim"
command wget "http://www.vim.org/scripts/download_script.php?src_id=8743" \
--output-document=- \
| command tar --directory "${HOME}/.vim/" -oxvzf -
Align
Requires : Vimball
This plugin ease code alignment. Install Align:
command wget "http://www.vim.org/scripts/download_script.php?src_id=10110" \
--output-document="/tmp/Align.vba.gz"
command vim -c "so %" -c "q" "/tmp/Align.vba.gz"
command rm "/tmp/Align.vba.gz"
SQL Utilities
Requires : Align
SQL Utilities ease the creation of SQL queries. It provides a SQL query formatting feature. Install SQL Utilities:
command wget "http://www.vim.org/scripts/download_script.php?src_id=9825" \
--output-document="/tmp/sqlutil_300.zip"
command unzip -qq -d "${HOME}/.vim" "/tmp/sqlutil_300.zip"
command rm "/tmp/sqlutil_300.zip"
This plugin features are available in “Plugin -> SQLUtil” menu.
Bibliography
- vi and Vim Editors Pocket Reference.
- Practical Vim: Edit Text at the Speed of Thought.
- Modern Vim: Craft Your Development Environment with Vim 8 and Neovim.
- Mastering Vim: Build a software development environment with Vim and Neovim.
Thanks
- Thanks to Vim (en) developers.
- Thanks to NeoVim (en) developers.
- Thanks to vim extension scripts (en) creators.
- Thanks to Tobias Schlitt (en) for phpDocumentor for Vim (en).
- Thanks to Charles Campbell (en) for Vimball (en).
- Thanks to Charles Campbell (en) for Align (en).
- Thanks to David Fishbum (en) for SQL Utilities (en).
0 Comments