vim-php-namespace is a vim script for inserting "use" statements automatically.
Automatically adds the corresponding use
statement for the class under the cursor.
To use this feature, add the following mappings in ~/.vimrc
:
inoremap <Leader>u <C-O>:call PhpInsertUse()<CR>
noremap <Leader>u :call PhpInsertUse()<CR>
Then, hitting \u
in normal or insert mode will import the class under the cursor.
<?php
new Response<-- cursor here or on the name; hit \u now to insert the use statement
Expands the class name under the cursor to its fully qualified name.
To use this feature, add the following mappings in ~/.vimrc
:
inoremap <Leader>e <C-O>:call PhpExpandClass()<CR>
noremap <Leader>e :call PhpExpandClass()<CR>
Then, hitting \e
in normal or insert mode will expand the class name to a fully qualified name.
<?php
$this->getMock('RouterInterface<-- cursor here or on the name; hit \e now to expand the class name'
Using pathogen
git clone git://github.com/arnaud-lb/vim-php-namespace.git ~/.vim/bundle/vim-php-namespace
Using vundle
Add to vimrc:
Bundle 'arnaud-lb/vim-php-namespace'
Run command in vim:
:BundleInstall
Download and copy plugin/phpns.vim
to ~/.vim/plugin/
The plugin makes use of tag files. If you don't already use a tag file you may create one with the following command; after having installed the ctags
or ctags-exuberant
package:
ctags-exuberant -R --PHP-kinds=+cf
or
ctags -R --PHP-kinds=+cf
The AutoTags plugin can update the tag file every time you modify or create a file under vim.
See Features section for adding key mappings.
The <Leader>
key usually is \
.
- Arnaud Le Blanc
- Contributors
This is based on an equivalent script for java packages found at http://vim.wikia.com/wiki/Add_Java_import_statements_automatically (in comments).