vim :make without external window

标签 vim makefile

在vim中,当我使用时

:make

make 的输出显示在“外部”窗口中,我不喜欢这个,我使用这个映射

 nnoremap <leader>m :w <bar> make<CR><CR><CR>:copen<CR>

但是,在某些情况下 make 的输出是

 make: Nothing to be done for `all'.

当 copen 有 make: Nothing to be done for all. 时,如何为 copen 添加自动关闭功能?

最佳答案

您可以通过getqflist()检查quickfix列表的内容。然后,如果第一行与您不想看到的文本不匹配,我只会有条件地打开快速修复窗口:

nnoremap <leader>m :w <bar> make<CR><CR><CR>
\:if get(get(getqflist(), 0, {}), 'text', '') !~# 'Nothing to be done' <Bar> 
\  copen <Bar>
\endif<CR>

通过 get() 进行访问可以避免列表为空时出现错误。

您也可以随时打开列表,然后在条件中使用 :cclose(如果这更适合您的需求)。

关于vim :make without external window,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12865090/

相关文章:

vim - 为什么在 gnome-terminal 和 gnu-screen 中运行时默认的 vim 背景选项不同?

vim - `.vimrc`中颜色和颜色方案之间的区别

vim - 为什么 Vim 这么慢?

regex - Vim用另一个相同长度的单词列表替换单词列表?

python - 在 vimscript 中使用 Python : How to export a value from a python script back to vim?

makefile - $<(美元符号+左三角括号)在makefile中是什么意思?

c - 在 C 中使用 extern 无法按预期工作

c - Flex 和 Bison 在使用结构体指针作为 union 类型时会出现问题

linux - 为什么在 omap 器件的 TI x-loader makefile 中使用 $$PWD 而不是 $PWD

c - 将目标文件存储在构建目录中 (Makefile)