3

makeprg=xcodebuild在 vim中设置的最佳方法是什么?

我在文件中使用 filetype 行,通过将文件的第一行设置为:

/* vim: set filetype=objc : */

并在 vimrc 中有这个:

set modelines=1

我可能想用:mak在当前目录中运行这个命令:

xcodebuild -activetarget -activeconfiguration

我通常最终手动设置xcodebuildmakeprg以便我可以:mak进行编译。

我总是在我有.xcodeproj文件的项目根目录中,所以我不必担心搜索项目文件。

最好的设置方法是makeprg什么?Ftplugin? Compiler插入?

任何想法表示赞赏。

4

2 回答 2

1

我会说ftplugin,这很容易。写在.vim/ftplugin/objc.vim

set makeprg=xcodebuild\ -activetarget\ -activeconfiguration

此外,如果 Vim 的文件类型检测器在前十行中发现#include#import或,它将认为您的 .m 文件是 Objective-C 文件。/*您可以编写一个ftdetect插件来更改默认值.vim/ftdetect/objc.vim::

autocmd BufNewFile,BufReadPost *.m set filetype=objc
于 2009-12-04T12:43:48.433 回答
1

你可以在你的 .vimrc 中加入如下内容:

if len(glob( getcwd() . '/*.xcodeproj' )) > 0
    let &makeprg = 'xcodebuild'
endif

所以当你启动 vim 并且当前目录中有一个 *.xcodeproj 时,它会将 makeprg 设置为 xcodebuild。

于 2009-12-04T15:48:38.137 回答