• Category Archives Vim
  • Local .vimrc for projects

    Thanks to Johan Westin that tipped me about this page 🙂
    See vimninjas.com for the whole article.

    Create a file called “vimrc-local.vim” in the ~/.vim/plugin/ directory. After that, put the following 5 lines of code in it:

     


  • Fix to vims taglist plugin (ctags tags comments in PHP)

    Taglist uses exuberant ctags, which supports many languages including PHP. I use vim on a daily basis to edit PHP files. Often classes and functions have PHPDoc and some like to use the words ‘class’ or ‘function’ in their comments. Fair enough, but ctags regex strings ignores that lines may have a preceding ‘*’ or ‘//’ and thus create tags of funny classes and functions. In some cases browsing large files of PHP source code with taglist is pointless.

    The solution to this is writing your own ctags configuration file (~/.ctags) and letting ctags know what regex strings You want to tag your PHP files with:


    -f ./tags
    --langmap=php:+.inc
    -h '.php.inc'
    -R
    --totals=yes
    --tag-relative=yes
    --PHP-kinds=+cf-v
    --regex-PHP
    --regex-PHP=/(^|^[^*]+[[:blank:]])class[[:blank:]]+([[:alpha:]][[:alnum:]_]*)/\2/c/
    --regex-PHP=/(^|^[^*]+[[:blank:]])function[[:blank:]]+&?[[:blank:]]*([[:alpha:]][[:alnum:]_]*)/\2/f/


  • Customer spesific settings in vim using git branches

    I work as an consultant and thus write code for different customers that may have quite different coding standards and license policies. Adapting to a customer often involves changing many files in the vim config files and plugins, but after I initialized a git repo in my ~/.vim folder I only have to change branch for each customer I work for. git br (git branch) gives me a neat list of predefined customer settings to choose from. Then its just git co [customer] and start to work.