andmarti1424 / sc-im

sc-im - Spreadsheet Calculator Improvised -- An ncurses spreadsheet program for terminal
Other
4.86k stars 207 forks source link

How to select and sum a range? #742

Closed Friptick closed 2 years ago

Friptick commented 2 years ago

Hello, thanks for your work. I am not a spreadsheet user and this will be the dumbest question you have ever heard. But I promise have just spent an hour with the docs and I'm not getting anywhere.

In my sheet, I want to see the sum total of the values of a bunch of cells from the same column. The cells are not contiguous, i.e. they will be, say, B2,B3,B6,B7,B8.

How would I go about this, without getting out a pocket calculator?

Logically this involves selecting the cells in Visual mode, but I can't see how. If I do ^o or ^k as advised by the manual, the sheet freezes and a ? appears top right. Confused.

andmarti1424 commented 2 years ago

Hello. I think you can select them using a mouse (if you have). Or you can insert the cells manually. Both in insert mode.

Friptick commented 2 years ago

Thanks. Was hoping to stay on the keyboard. It would be great to have some kind of temporary buffer for marking cells with the keyboard. The file manager Ranger has ya to "yank add" files and uy to wipe the buffer, for example.

Then the sum of the buffer could be displayed in the status bar, for instance. The objective is just to make it simpler to do on-the-fly throwaway calculations. I believe Excel does something like this.

Anyway, I'm still having trouble with the range: =@sum(C30,C32:C37) - syntax error. =@sum(C30+C32:C37) - syntax error.

Can't find anything in the manual about range syntax. Help?

andmarti1424 commented 2 years ago

You can enter insert mode with =, then C-v to enter visual mode to select the cell or range of cells, then C-o and C-k to begin selection and confirm selection, and then ENTER twice to copy the cell or range to formula. Cannot remember why two ENTER pressings were needed but the rest is on the doc file.

About the syntax, this would achieve what you want: =C30+@sum(C32:C37) or =@sum(C30)+@sum(C32:C37)

andmarti1424 commented 2 years ago

The dual ENTER pressings is a terminal issue with C-k. It happens to me inside tmux. It might not happen to you. You can also just:

= to enter insert mode
C-v to enter visual mode
at this time you can move to the desidered cell or start of range
C-o to begin selection
at this time you can confirm just one cell or move to another cell that would represent the end of a range.
ENTER to confirm selection 
Friptick commented 2 years ago

Works. With a single ENTER and the syntax you outlined. Something tells me I'm gonna be coming back to this post when I need to do it again next month. :)

Thanks for your patience and your work on this project. Closing.