A recent video from Linus Tech Tips introduced how one of their editors uses macros for video editing. This got me thinking; can macros be easily created to improve my programming?
This video demonstrates how creating code macros can be achieved and how useful it can be:
As mentioned, the idea came following watching the Linus Tech Tips video. Now he perhaps took this a little far with 3 keyboards dedicated to just macros (as shown in the image above). However, I already happened to be using one that had some macro keys so why not utilise it.
The keyboard I have it the Logitech G910 and it has 9 macro keys with 3 profiles for a total of 27 possible combinations.
How it Works
Fortunately, the Logitech software makes this pretty easy but it should be simple to replicate with other devices. I simply assigned each macro to create a text block that pasted some pre-defined code.
I assigned 5 keys with 2 profiles for a total of 10 macros. These are shown in the image below and demonstrated fully in the video.
Each macro pastes the pre-defined code making it quick and easy to perform some tasks such as:
- Importing packages/dependences
- Import/export data
- Create plots with set formatting
- Create for loops
- Define functions
- Create LaTeX equations for markdown cells
These were just the main use cases I have found for this but am sure each person will have their own ideas based on their requirements.
I hope you found this useful for your own data science tasks