Vim: Cucumber imprint for "And" lines

In the language of cucumbers Gherkin, he allowed indents and lines, for example:

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 same indentation style, but with the Cucumber type scripts for Vim , I have to manually indent And the lines and manually select the following lines, and sometimes Vim automatically indents, and it all ends.

What is the best way to work with indentation and lines in Vim? Or is it easiest to abandon it?

+4
source share
2 answers

I think you can configure indent/cucumber.vim (online here ) to increase the indentation in lines starting with ^\s*And .

+2
source

Here's the diff for indent/cucumber.vim based on Andy's answer:

 --- .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 
+2
source

Source: https://habr.com/ru/post/1344402/


All Articles