开发者

Separate srcdir and objdir with vim and gcc

When I'm working in vim, my current working directory (./) contains all my source. I build in an objdir, let's call it ./builddir/. When I build from vim, using makeprg=make\ -C\ builddir, the compiler warnings and errors all have a prefix of ../, which means vim brings the cursor to a file which doesn't exist.

If I try a different tactic, launching vim from the objdir, then开发者_开发技巧 I can't do commands like gf or :e myfile.h simply.

Is there a middle ground where all of this will work, like giving vim a second directory to search from if it can't find files in the current working directory? Or maybe getting gcc to use a different prefix?


The most simple solution would be to filter make outputs with sed to replace the output pathnames. (I've implemented a very similar thing to convert cygwin pathnames into windows pathnames for the win32 flavour of vim).

Something like:

:let &makeprg .= '2>&1 | sed "s#^\.\./##g"'

(It may be \| and not |, I don't remember)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜