开发者

Vim errorformat: using %D to change directory

开发者 https://www.devze.com 2023-03-09 22:41 出处:网络
I\'m struggling to find the right Vim errorformat to use when the current directory is a sibling of the directory with the file with the error. For example:

I'm struggling to find the right Vim errorformat to use when the current directory is a sibling of the directory with the file with the error. For example:

errorformat
errorformat/model
errorformat/spec

Vim's makeprg option is set to execute a file in errorformat/spec. I run make from errorformat/model. Vim is set up to use the current file's directory as the working directory.

To test, I'm running the following in errorformat/model/errorformat.vim

set makeprg=ruby\ ~/errorformat/spec/errorformat_spec.rb
let &efm="%D%f,%f:%l"
make!
copen

As you can see, that runs a Ruby file in the sibling directory which simply does

puts %{errorformat}
puts %{./spec/errorformat_spec.rb:1}
exit 5

The desired effect is that when I run the spec from a different directory, Vim will use the %D in the errorformat to let me open the spec file. But it's not working. In particular, I just can't seem to get %D%f to do what I expect. When I run this test, the QuickFix window shows

|| errorformat
|| ./spec/errorformat_spec.rb:1

The double bars are indicating that the %D%f part of the errorformat 开发者_如何学Pythonisn't recognizing the output. This also seems to prevent the next line from being interpreted by the %f:%l part.

There must be something very simple I'm missing!


The problem was with the order of the errorformat. The %D%f part needed to go after the %f:%l part.

0

精彩评论

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