I'm using vim, and I have used ctags and placed this in the ctags config file as per this post:

--regex-php=/^[ \t]*trait[ \t]+([a-z0_9_]+)/\1/t,traits/i

the problem is that I still can't find the trait.. so for example in this code:

    /*Mark user as verified first*/
    $user = App\User::find($this->getClient()->id);
    $user->is_verified = true;

pressing ctrl] on my mac returns this:

> tags
 prt  path  <mru>={ files }=<buf> <->                                                                                                                                                                                                          /Users/Shared/dev/php/toters-api
>>> _

jumping to definition in php storm on the same file works fine, and takes me here:

trait ClientHelpers{

private $client      = null;
private $clientToken = null;

protected function getClient()
    if (!$this->client) {
    return $this->client;



i checked the contents of my tags file, and getClient exists there!

getClient       tests/Helpers/ClientHelpers.php /^    protected function getClient()$/;"        f       trait:ClientHelpers

which is weird. for completion sake, here is my vimrc file.

second update

:tags getClient works!

and i removed this part from my vimrc file " The Silver Searcher if executable('ag') " Use ag over grep set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ tags

  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g --ignore tags""'

  " ag is fast enough that CtrlP doesn't need to cache
  let g:ctrlp_use_caching = 0

and now when i enter ctrl] on top of getClient I get this

enter image description here

enter image description here

update 3

it turns out i was pressing the wrong key.. :( it works fine now!

  • Perhaps you should try-out another implementation of ctags. Exuberant ctag development is stalled for years but there is an active fork: Universal ctags. Perhaps it already support the feature you want.
    – fievel
    Oct 19, 2017 at 9:43
  • that's the one i got installed.. $ ctags --version Universal Ctags 0.0.0(ccac4df), Copyright (C) 2015 Universal Ctags Team Universal Ctags is derived from Exuberant Ctags. Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert Compiled: Oct 19 2017, 12:02:27 URL: https://ctags.io/ Optional compiled features: +wildcards, +regex, +multibyte, +option-directory, +xpath, +case-insensitive-filenames
    – abbood
    Oct 19, 2017 at 9:57

1 Answer 1


When you press Ctrl-P in normal mode, you are invoking the Ctrl-P plugin, and it is displaying a fuzzy finder for files, (with the first entry being the tags file you've created with ctags).

If your cursor is over getClient(), the keystroke you need to use to jump to its definition is Ctrl+].

If this doesn't work, then the first thing to check is whether the getClient tag actually exists in your tags file. You can do this by opening it in Vim and searching. If the tag doesn't exist, then you'll need to fix the command you are using to invoke ctags.

  • my bad i mistyped the key combo i was using, it was indeed ctrl-] all along. then you'll need to fix the command you are using to invoke ctags... that's exactly what i'm asking
    – abbood
    Oct 19, 2017 at 10:26
  • @abbood You also copied and pasted the Ctrl-P output into your question, so it looks like you've remapped ctrl-] to invoke Ctrl-P too.
    – Rich
    Oct 19, 2017 at 10:32
  • normally when i press ctrl-] i go to the definition. it's just that when i do that with traits, it doesn't find it.. this is the contents of my vimrc file though
    – abbood
    Oct 19, 2017 at 10:44
  • but you are right about getclient being inside my tags file.. so now i'm not sure what's going on 🤔
    – abbood
    Oct 19, 2017 at 10:47
  • @abbood Does :tag getClient work correctly?
    – Rich
    Oct 19, 2017 at 10:49

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