VIM计数/确定quickfix中的错误数
发布时间:2020-12-16 01:30:50 所属栏目:安全 来源:网络整理
导读:这可能听起来很愚蠢,但我没有在帮助中找到它. 如何确定QuickFix中的错误数量,运行后:make? 或者至少看看是否有任何错误,即错误 0? 您可以使用getqflist()以编程方式获取错误列表: getqflist() *getqflist()* Returns a list with all the current quickf
|
这可能听起来很愚蠢,但我没有在帮助中找到它.
如何确定QuickFix中的错误数量,运行后:make? 或者至少看看是否有任何错误,即错误> 0?
您可以使用getqflist()以编程方式获取错误列表:
getqflist() *getqflist()*
Returns a list with all the current quickfix errors. Each
list item is a dictionary with these entries:
bufnr number of buffer that has the file name,use
bufname() to get the name
lnum line number in the buffer (first line is 1)
col column number (first column is 1)
vcol non-zero: "col" is visual column
zero: "col" is byte index
nr error number
pattern search pattern used to locate the error
text description of the error
type type of the error,'E','1',etc.
valid non-zero: recognized error message
When there is no error list or it's empty an empty list is
returned. Quickfix list entries with non-existing buffer
number are returned with "bufnr" set to zero.
Useful application: Find pattern matches in multiple files and
do something with them: >
:vimgrep /theword/jg *.c
:for d in getqflist()
: echo bufname(d.bufnr) ':' d.lnum '=' d.text
:endfor
如果您只想要总数,请使用len(getqflist()).例如: :echo len(getqflist()) 如果你只想交互式地知道:cw将在窗口中打开列表,如果有任何错误(如果它已经打开并且没有错误就关闭它).该缓冲区中的行数是错误数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
