Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 –  rxt Apr 8 at 11:53
add comment

3 Answers

to generate tags for ctags, you'll need exuberant-ctags. Here's the site: http://ctags.sourceforge.net/

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:
https://github.com/majutsushi/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
add comment

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.