La Vita è Bella
Tuesday, March 02, 2010
More tips about my projtags.vim
I wrote a vim plugin named projtags, initially for loading tags file for projects. But as I can "set tags+=tags;" in my vimrc, it's not that useful on the tags file way. I expanded its feature to support commands for per projects, and this is much more useful
Here are some examples:
Case 1: different coding styles
I did some squid hacking before. My coding style is as below:
set cindent
set autoindent
set smartindent
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
set smarttab
set cino=:0,g0,t0
But squid coding style is different. They use 4 for shiftwidth. As hacking some project, you should always follow the original coding style. But add vim modeline into every file is also unacceptable. So I use projtags.vim to do this job:
let g:ProjTags += [["~/work/squid", ":set sw=4"]]
So that every time I'm editing a file within squid, vim will use 4 instead of 8 for shiftwidth, now I'm happy with both my own codes and squid codes.
Case 2: use ant as makeprg for java projects
First, I use a autocmd to set ant as makeprg for java files:
autocmd BufNewFile,BufRead *.java :setlocal makeprg=ant\ -s\ build.xml
It works well for java files. But as I did some Android development these days, I also have lots of xml files to edit (and then make to see the result). I can't use such a autocmd for xml's, as not all xml's are in a java project. So projtags.vim is again the answer:
let g:ProjTags += [["~/work/pmats", ":set mp=ant\\ -s\\ build.xml"]]
So I can always use ":make" for ant under my Android project now, no matter it's .java or .xml.
My vimrc segment for tags and projtags
set tags+=/usr/local/include/tags
set tags+=/usr/include/tags
set tags+=/opt/local/include/tags
set tags+=tags;
let g:ProjTags = []
let g:ProjTags += [["~/work/squid", ":set sw=4"]]
let g:ProjTags += [["~/work/pmats", ":set mp=ant\\ -s\\ build.xml"]]
Patches for projtags.vim (e.g. Windows support, I haven't tested it but I guess it won't work under Windows now) are welcomed
You can get the code from the git repo for my various scripts.
tags: dev, vim, tags, projtags
19:58:01 by fishy - dev - Permanent Link
Revision: 1.1/1.1, last modified on 2010-03- 2 @ 20:00.
Karma: 2 (66.67% out of 6 were positive) [+/-]
You can subscribe to RSS 2.0 feed for comments and trackbacks
Trackbacks:There are currently no trackbacks for this item.Use this TrackBack url to ping this item (right-click, copy link target). If your blog does not support Trackbacks you can manually add your trackback by using this form.
![]()
Javier wrote:
I have downloaded the plugin ( i'm very interested because have to work with many proyects ... ) but with entries like this
let g
rojTags = ["~/prj/pruebas/data/kernel/linux-2.6/"]
i have the error E488: (traling characters at the end of line or something like this )
The code goes thru the 'catch' -item is no a list ,...
it seems like the 'let filepattern = item . "*"' doesn't not works so I have changed by
'let filepattern = item' ... so without '*' now it works .
Friday, April 09, 2010 18:16:33
![]()
@Javier: you need double bracelet like this:
let g
rojTags = [["~/prj/pruebas/data/kernel/linux-2.6/"]]
Friday, April 09, 2010 18:19:42
![]()
Javier wrote:
ops , sorry ,
thanks
Friday, April 09, 2010 18:24:12





