如何有效地“制造"使用 Vim [英] How to efficiently "make" with Vim

查看:20
本文介绍了如何有效地“制造"使用 Vim的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做的事情似乎是非常基本的东西,但我找不到任何关于它的信息.我正在照常构建一个项目:

What I am trying to do seems a very basic stuff, but I can't find anything about it. I am working on a project built as usual:

project
|-- bin
|-- inc
`-- src

我想使用 Vim 中包含的 make 命令来制作我的项目.但每次我都必须指定 :make -C ../.我更愿意,如果当前目录中没有 Makefile 文件,请进入父目录.我已经用

I would like to make my project using the make command included in Vim. But each time I have to specify :make -C ../. I would prefer, if there is not Makefile file in the current directory, go in the parent directory. I already do that with

set tags+=./tags;/

在我的 .vimrc 中.

此外,默认情况下,make 是丑陋的.是否有添加颜色的选项,并允许直接访问错误(如在 Emacs 中).

Furthermore, the make is by default ugly. Are there options to add color to make, and allow a direct access to the errors (as in Emacs).

谢谢

推荐答案

rampion 的解决方案是第一步,但在 vim 负载上计算.当我加载多选项卡会话时,从一个选项卡到另一个选项卡的路径可能不一致.

The solution of rampion is a first step, but computed on vim load. When I load a multi tab session, the path can be inconsistent from one tab to another.

这是我的解决方案(+ 额外的 tabnew).

Here my solution (+ extra with tabnew).

fun! SetMkfile()
  let filemk = "Makefile"
  let pathmk = "./"
  let depth = 1
  while depth < 4
    if filereadable(pathmk . filemk)
      return pathmk
    endif
    let depth += 1
    let pathmk = "../" . pathmk
  endwhile
  return "."
endf

command! -nargs=* Make tabnew | let $mkpath = SetMkfile() | make <args> -C $mkpath | cwindow 10

这篇关于如何有效地“制造"使用 Vim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆