[英]Vim: Cucumber indentation for “And” lines
In Cucumber's Gherkin language, it's allowed to indent And lines, like so: 在Cucumber的Gherkin语言中,它允许缩进和行,如下所示:
Scenario:
Given there is a user named Chris
And I am logged in as Chris
When I go to the home page
Then I should see "hi Chris"
And I should not see "log in"
I like this indentation style much better than the equally-indented style, but with Tim's Cucumber scripts for Vim , I have to manually indent the And lines and manually dedent the following lines, and sometimes Vim will automatically indent lines and it ends up all wrong. 我喜欢这种缩进样式比同样缩进的样式好得多,但是对于Vim的 Tim's Cucumber脚本 ,我必须手动缩进And行并手动调整以下行,有时候Vim会自动缩进行并且它最终都会出错。
What's the best way to work with indented And lines in Vim? 在Vim中使用缩进和线条的最佳方法是什么? Or is it easiest to just give up on it? 或者最容易放弃它?
我想你可以自定义indent/cucumber.vim
( 在这里在线)来增加从^\\s*And
开始的行的缩进。
Here's a diff for indent/cucumber.vim
based on Andy's answer: 根据Andy的回答,这是indent/cucumber.vim
的差异:
--- .vim/indent/cucumber.vim.bak 2011-03-24 18:44:27.000000000 +0100
+++ .vim/indent/cucumber.vim 2011-03-24 19:09:41.000000000 +0100
@@ -47,6 +47,10 @@
return indent(prevnonblank(v:lnum-1)) + &sw
elseif cline =~# '^\s*[^|# \t]' && line =~# '^\s*|'
return indent(prevnonblank(v:lnum-1)) - &sw
+ elseif cline =~# '^\s*\%(And\|But\)' && line !~# '^\s*\%(And\|But\)'
+ return indent(prevnonblank(v:lnum-1)) + &sw
+ elseif cline !~# '^\s*\%(And\|But\)' && line =~# '^\s*\%(And\|But\)'
+ return indent(prevnonblank(v:lnum-1)) - &sw
elseif cline =~# '^\s*$' && line =~# '^\s*|'
let in = indent(prevnonblank(v:lnum-1))
return in == indent(v:lnum) ? in : in - &sw
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.