Â
Much of our work has changed tremendously in the era of generative AI. This includes coding work, where the large language model (LLM) tremendously boosts the process.
Recently, many code-assisting tools powered by generative AI have been launched. Many do the same things, but one tool that catches the public’s eye is Cursor. Cursor is an AI-powered Code Editor designed for developers to focus on improving their working experience rather than only fixing their code.
The cursor is helpful to developers, including data scientists. This article will explore how to use the IDE effectively for 10x coding.
How does it work? Let’s get into it.
Â
Effectively Using Cursor
Â
Cursor is an IDE that was initially a fork of VS Code, so it will be easy for you to jump into Cursor if you are already familiar with the latter.
As I mentioned above, Cursor is an IDE powered by Generative AI that helps us code. But how exactly does the Cursor help? There are many features available, but generally, Cursor helps you in three ways:
- Code Autocomplete
- Chatting with your Codebase
- Edit and Write your Code
Those are the general features you can expect from Cursor, but we will explore in more detail how to use Cursor effectively.
As a reminder, the code quality will depend on the LLM model you use. As of the time this article was written, Cursor only allows the GPT family, Claude family, and Cursor Small model. It’s also possible to use the Google model, but you need to assign your API key.
Speaking of assigning your API key, all the family models above can be accessed via your API key if you want to use expenses coming from your account. If not, you can access the premium model with a Cursor subscription. The Cursor Small model is always free, but the quality might be better than that of the other model.
Let’s start using Cursor for our work. Before we begin, ensure that you have installed Cursor in your environment.
Â
Code Generation and Editing
Â
We will try out the code generation feature. To do that, press the Ctrl + K button, and the text bar will appear.
For the example. We generate the script to read the CSV data and train the model. You can follow the prompt below.
Â
Â
As you can see in the above image, the generated code is available instantly. You can choose to accept the code, reject it, or put a follow-up instruction in it.
Another example of code generation is using existing code and working based on that. In the image below, we will ask Cursor for further options for model evaluation, and Cursor will provide them.
Â
Â
When you already have the code generated or have the script in your environment, Cursor can suggest appropriate code for our work. If you accept them, you only need to press the tab button, and the code will be generated.
Â
Â
Even if you write the code carelessly, Cursor can help you fix it and gauge your intention.
Â
Â
With all the features above, you will improve your work efficiency in developing your data science project.
Â
Chat with Your Codebase
Â
The other feature that Cursor is good at is to allow you to chat with your code. By chatting, you can specifically chat on your whole code script or a particular part of the code. Either way, press the Ctrl + L button to chat with your code.
For example, we chatted with our previously generated code as a reference, and we asked to improve the code.
Â
Â
As the image above shows, the Cursor explains your instructions and code suggestions. It will not automatically apply the code to your code, as we need to press the Apply button to apply the suggestion.
Â
Â
Then, you should accept the changes for each transformed code as well. The transformation will not remove your original code until you agree with the changes.
Â
Â
Next, the chat feature allows you to mention additional files from your environment or even the internet. The cursor called it a “mention” feature.
Â
Â
For example, we will ask Cursor to scour the web to improve our code, as in the image below.
Â
Â
Just like the previous example, the code result needs to be applied manually.
Lastly, it’s possible to attach images in the chat features. By doing that, we can chat with our codes while also having image references.
For example, I want to produce a specific plot like the image I have from the current code I have. In this case, I could attach an example of my image and ask the Cursor to provide instructions on how to generate the plot.
Â
Â
The mentioned feature is mighty as you can attach many things while you can keep following up with whatever you need.
That’s all you need to know to use Cursor effectively.
Â
Conclusion
Â
Cursor is a programming IDE that is designed to assist developers in coding works with Generative AI. Mainly there are three main features you can use to use Cursor effectively:
- Code Autocomplete
- Chatting with your Codebase
- Edit and Write your Code
By utilizing all the features above, you can improve your coding work by 10x. The IDE development is still in progress as well, so keep paying attention to the Cursor features that might help your work.
I hope this has helped!
Â
Â
Cornellius Yudha Wijaya is a data science assistant manager and data writer. While working full-time at Allianz Indonesia, he loves to share Python and data tips via social media and writing media. Cornellius writes on a variety of AI and machine learning topics.