Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying a lot (but not smartly) to figure out setting up VIM, ctags, omnicomple for PHP development.

On Googling I found this file. But have no clue how to use it.

What have I done until now? Here it is:

  1. I am on Fedora 17 64-bit OS
  2. Logged in as root Found my VIM version to be VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 8 2012 15:05:51)
  3. Followed the install details as here http://www.vim.org/scripts/script.php?script_id=3171

install details Place in $HOME/.vim/autoload/phpcomplete.vim and enable the php ftplugin

What else I am missing? How do I start using omnicomplete. (this is the first time I am using omnicomplete)

Why didn't I try IDE's?

I have a single core machine running LAMP stack. Didn't wanted to slow down everything and hence sticking to command line environment.

share|improve this question
    
Not directly related, but it may improve VIM... You can install a different color scheme, one that is more (or less) subtle, depending on what you need or like. cocopon.me/app/vim-color-gallery and vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own – SPRBRN Apr 8 '14 at 11:53

Vim already does PHP completion. The file in question is only an improvement over the default function. Anyway, to make it really useful you'll need a tags file that you generate with exuberant-ctags.

Read :help ins-completion, specifically the part on "omni completion", and :help ft-php-omni.

And you missed an important step: google "vim php ide" (without the quotes).

share|improve this answer

Look at my VIM config: https://github.com/exu/vim-dotfiles

  • I'm using PIV (PHP Integration For VIM) + CTags (exuberant-ctags)

For tag generation I use command below:

ctags-exuberant -f tags \
    -h ".php" -R \
    --PHP-kinds=cfiv \
    --totals=yes \
    --tag-relative=yes \
    --PHP-kinds=cfiv \
    --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \
    --regex-PHP='/interface\s+([^ ]+)/\1/i/' \
    --exclude="*.js" \
    --exclude=".svn" \
    --exclude=".git"

UltiSnips as snippets for code generation (most powerfull snippets for VIM)

Look at my .vimrc, there are some PHP related things too.

share|improve this answer

to generate tags for ctags, you'll need exuberant-ctags.

Pseudo steps to follow:

1) install exuberant-ctags on machine
2) issue ctags command in command line (what @jacek wrote)
3) in vim, normal mode, type:

:set tags=<tags location>

4) You can now use Ctrl-] like commands to view function definitions.

TagBar can be used to show function & variable names of local buffers: Github tagbar

To save typing step (4) every time vim starts, I have the following in my vimrc to do php specific setups:

autocmd FileType php call SetPHPOptions()
function! SetPHPOptions()
    setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab makeprg=php-xdebug\ %
    :call tagbar#autoopen(0)
    :set tags=~/.vim/php.tags
endfunction
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .