Objective-C Exuberant Ctags Regex

I just finished taking a look at improving my Objective-C ctags regex, as Exuberant Ctags doesn’t support the language directly. I wasn’t really able to find anything helpful so for anyone interested these are the lines in my ~/.ctags file that I use for Objective-C tags creation. They’re certainly not perfect but they do a reasonable job for me. Suggestions and improvements are very welcome.


For completeness this is the line in my ~/.vimrc for use with the TagList plugin.

let tlist_objc_settings    = 'objc;i:interface;c:class;m:method;p:property'

Leave a Reply


Responses to “Objective-C Exuberant Ctags Regex”

  1. Thank you for posting this. It was very helpful in my battle to get tags working correctly for obj-c files. Just curious- do you use autotag.vim or easytags.vim scripts to keep your tag file(s) up to date?

    • No I don’t use either of those. I do have this in my .vimrc to help with tags generation though:

      "build ctags for the cwd
      :nmap <leader>ct :!ctags -R *<CR>

      I then override this for specific file types if I want to add flags, for example in C# I use this.

      autocmd FileType cs :nmap <buffer> <leader>ct :exec "!ctags -R --extra=+fq --fields=+ianmzS --c\\#-kinds=cimnp ."<CR>

  2. Yes indeed, thanks for sharing!

    I just found a reference to a ctags fork with Objective-C support, but I haven’t tried it yet — hope that work can get merged upstream:


    • @Ches Martin- Have you had a chance to try it yet? I can’t seem to get it to work. The tag file I create using version 5.8.1 of ctags only seemed to have @properties (no methods)

    • This looks like a great find. It’s about time ctags got some attention. I might have a play with this if I can find some time!

  3. It works!
    Do you know how to support “.mm” file?
    .mm file can support objective-c and c++.
    I modified .ctags –langmap to add .mm, but it does not work!

    • I mean Taglist not works!

      • When I open a *.mm file in Vim it detects it as of ‘nroff’ filetype. This means that the taglist plugin won’t be using objective-c definitions to generate the tags. Try issuing :set ft=objc on a *.mm file. This should allow taglist to work. You can have this automatically happen by putting the following autocmd in your .vimrc.

        autocmd BufRead,BufNewFile *.mm :set ft=objc

        Hope this helps. Let me know how you get on.

        • Awesome!
          It works!
          I don’t know ‘autocmd’ before,
          but enriching my knowledge now.
          Thank you very much!

        • Do you use other vim plugins (e.g. cocoa.vim, snipMate.vim) to finish something like
          method/class/variable completion?

          if Yes, could you introduce the plugins?

  4. Mario Gajardo Tassara December 15th, 2011 - 10:30 pm

    Thank you very much !!!

    I was searching this for ages, now i can do my objective-c coding more pleasant !!, thank again.

  5. |

  6. Hi my name is Jacqueline and I just wanted to drop you a quick note here instead of calling you. I came to your Objective-C Exuberant Ctags Regex | gregsexton.org page and noticed you could have a lot more hits. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your subject matter. There is a company that you can get targeted traffic from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my site. Visit them here: http://zoy.bz/4nn

  7. lic aao syllabus March 2nd, 2016 - 9:36 am

    We are a gagle of volunteers and starting a neww scheme in oour community.
    Your site provided us with useful info tto work on. Yoou have performed a
    formidable job and ourr whole group might be grateful to you.

  • Kyle Wellwood Jerseys
  • -->