From 33ea774b69115236327a7caa58856c89e3e40874 Mon Sep 17 00:00:00 2001 From: Cameron Fowler Date: Thu, 21 Jul 2022 14:10:35 +1200 Subject: [PATCH] Support optional newline after tables for formula Fixes #86 This allows the formula line to be evaluated, even if there is a single empty line after the table. The "empty" line is allowed to contain whitespace, but nothing else. The formula will evaluate if triggered on the table, the empty line, or the formula lines. --- README.md | 7 ++++--- autoload/tablemode/spreadsheet/formula.vim | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b76f75..440045f 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,10 @@ it using `:TableModeRealign` or using the default mapping results. - You can directly add / manipulate formula expressions in the formula line. - The formula line is a commented line right after the table, beginning with - 'tmf:' (table mode formula). eg) `# tmf: $3=$2*$1`. You can add multiple - formulas on the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14` + The formula line is a commented line right after the table, or optionally + separated from the table by a single empty line. It begins with 'tmf:' + (table mode formula). eg) `# tmf: $3=$2*$1`. You can add multiple formulas on + the line separated with a ';' eg) `# tmf: $3=$2*$1;$4=$3/3.14` You can evaluate the formula line using `:TableEvalFormulaLine` or the mapping \tfe (defined by the option `g:table_mode_eval_expr_map`) diff --git a/autoload/tablemode/spreadsheet/formula.vim b/autoload/tablemode/spreadsheet/formula.vim index 0ae8eb0..c6ede5b 100644 --- a/autoload/tablemode/spreadsheet/formula.vim +++ b/autoload/tablemode/spreadsheet/formula.vim @@ -7,6 +7,10 @@ function! s:IsHTMLComment(line) "{{{2 return !s:IsFormulaLine(a:line) && getline(a:line) =~# '^\s*