dhruvasagar / vim-table-mode

VIM Table Mode for instant table creation.
2.1k stars 97 forks source link

How to get negative indices inside formula? #141

Closed lluke777 closed 5 years ago

lluke777 commented 5 years ago

Hi. Great plugin :) I am getting error using negative idices inside formula. How to properly call coordinates of last row and row before last inside such a formula?

tmf: $-2,3=$-2,2*$-1,3

In this example I want to put result in (here) place as a multiplication of Total and Tax.

| Food   | color  | price  |
|--------+--------+--------|
| Grape  | red    | 20     |
| Grape  | white  | 30     |
| Lemon  | yellow | 5      |
| Orange | orange | 10     |
| Banana | yellow | 20     |
|--------+--------+--------|
| Tax    | 1.15   | (here) |
| Total  | 0      | 65     |
/*  tmf: $-2,3=$-2,2*$-1,3 */
/* tmf: $-1,3=Sum(2:-1) */
dhruvasagar commented 5 years ago

Hi,

Actually, negative indices is supported only for the target row reference, not for inline within the formulas. I'll see if I can quickly add this and push.

PS : Why do you have 2 formula lines ? I am guessing that's a typo, you specify multiple formulas by separating them with ; on the single formula line.

dhruvasagar commented 5 years ago

Hi, having multiple formula lines also works, it was added via a pull request I forgot about. Thanks for your report, kindly have a look, it should work as expected with the latest changes.