Then I decide to edit the second condition in this contrived if by replacing this by a very log condition.
if 1 && some_var == 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
echo 'Ok'
endif
Now I see that the if-line is too long and decide to break it, say, before &&. After that I am getting
if 1
endif\ && some_var == 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
echo 'Ok'
endif
because the endwise rule for Vim filetype has triggered and put unexpected endif before the second part of the if condition. Notice that the endwise rule worked not-endwisely as the cursor was in the middle of the if condition before pressing the <Enter>.
The solution is simple: let the endwise rule trigger only when the cursor is at the end of line, here is my patch that makes the endwise rule work nicely.
diff --git a/autoload/lexima/endwise_rule.vim b/autoload/lexima/endwise_rule.vim
index 4f11f91..d52d71e 100644
--- a/autoload/lexima/endwise_rule.vim
+++ b/autoload/lexima/endwise_rule.vim
@@ -7,7 +7,7 @@ function! lexima#endwise_rule#make()
let rules = []
" vim
for at in ['fu', 'fun', 'func', 'funct', 'functi', 'functio', 'function', 'if', 'wh', 'whi', 'whil', 'while', 'for', 'try']
- call add(rules, s:make_rule('^\s*' . at . '\>.*\%#', 'end' . at, 'vim', []))
+ call add(rules, s:make_rule('^\s*' . at . '\>.*\%#$', 'end' . at, 'vim', []))
endfor
for at in ['aug', 'augroup']
It seems that other endwise rules require this treatment too.
Say, I edit some Vim script which contain
Then I decide to edit the second condition in this contrived
if
by replacing this by a very log condition.Now I see that the
if
-line is too long and decide to break it, say, before&&
. After that I am gettingbecause the endwise rule for Vim filetype has triggered and put unexpected
endif
before the second part of theif
condition. Notice that the endwise rule worked not-endwisely as the cursor was in the middle of theif
condition before pressing the<Enter>
.The solution is simple: let the endwise rule trigger only when the cursor is at the end of line, here is my patch that makes the endwise rule work nicely.
It seems that other endwise rules require this treatment too.