andmarti1424 / sc-im

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

Internal macros or aliases #274

Open slackhead opened 6 years ago

slackhead commented 6 years ago

I saw the thread on macros that run external lua scripts, but I'm wondering if there could be a way of making purely internal macros (using normal sc-im commands not lua). If there isn't yet then I'd like to make a feature request, unless there's a better/easier way of doing the same thing.

Example:

The following is a key bind that I made:

nmap "Z" "=@nval(@coltoa(@mycol),@myrow-1)+1209600kxPv:format \"d%d/%m/%Y\"j"

If used when the cursor is under a date it will calculate the date +2 weeks from the date above and output it as a new date. Running '10Z' will repeat it 10 times etc. This is very helpful for adding new date ranges that continue in a column of dates.

It would be nice if I could define that as a macro or alias so that it isn't taking up valuable keybind space, since it's hard to remember all the custom binds when you make many, and also running a command like eg :extend_dates would be easier to remember and be more descriptive.

The date thing is just an example though. The ability to do this would be very nice and I wouldn't think that the required code would be too different to the current nmapping code (not that I've looked at it!)

andmarti1424 commented 3 years ago

I believe macros would not be very difficult task to add. And very useful.

ghost commented 3 years ago

+1 for macros currently there is no binding to even increment or decrement integer values like vims <ctrl-a> and <ctrl-x>

Gitleptune commented 2 years ago

This was one of the first things which I came to sc-im for, sadly it isn't implemented yet.

But if/when it does I'd really like to be able to save my already made macros (in vim they get deleted when you close the file).

slackhead commented 2 years ago

If the macros follow the same rules as keybindings then perhaps the code could be reused, then perhaps all that's needed is a way to interpret custom commands?