Mercurial > vim
diff runtime/indent/vim.vim @ 14714:bdbb049c2aa8 v8.1.0369
patch 8.1.0369: continuation lines cannot contain comments
commit https://github.com/vim/vim/commit/67f8ab829911c7901c534ef2bf19cc34b622936f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 11 22:37:29 2018 +0200
patch 8.1.0369: continuation lines cannot contain comments
Problem: Continuation lines cannot contain comments.
Solution: Support using "\ .
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 11 Sep 2018 22:45:07 +0200 |
parents | 619a98a67f67 |
children | 1cd44535be32 |
line wrap: on
line diff
--- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -10,7 +10,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetVimIndent() -setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\ +setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\,0=\"\\\ let b:undo_indent = "setl indentkeys< indentexpr<" @@ -31,15 +31,17 @@ function GetVimIndent() endtry endfunc +let s:lineContPat = '^\s*\(\\\|"\\ \)' + function GetVimIndentIntern() " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) - " If the current line doesn't start with '\' and below a line that starts - " with '\', use the indent of the line above it. + " If the current line doesn't start with '\' or '"\ ' and below a line that + " starts with '\' or '"\ ', use the indent of the line above it. let cur_text = getline(v:lnum) - if cur_text !~ '^\s*\\' - while lnum > 0 && getline(lnum) =~ '^\s*\\' + if cur_text !~ s:lineContPat + while lnum > 0 && getline(lnum) =~ s:lineContPat let lnum = lnum - 1 endwhile endif @@ -51,10 +53,10 @@ function GetVimIndentIntern() let prev_text = getline(lnum) " Add a 'shiftwidth' after :if, :while, :try, :catch, :finally, :function - " and :else. Add it three times for a line that starts with '\' after - " a line that doesn't (or g:vim_indent_cont if it exists). + " and :else. Add it three times for a line that starts with '\' or '"\ ' + " after a line that doesn't (or g:vim_indent_cont if it exists). let ind = indent(lnum) - if cur_text =~ '^\s*\\' && v:lnum > 1 && prev_text !~ '^\s*\\' + if cur_text =~ s:lineContPat && v:lnum > 1 && prev_text !~ s:lineContPat if exists("g:vim_indent_cont") let ind = ind + g:vim_indent_cont else