Inline generation with “CMD + K” (Prompt bar)
Inline generation with “CMD + K” (Prompt bar)
Let’s start with the code editor. Think of the Prompt Bar as your personal chef in the kitchen of your codebase. First, we need a simple recipe. Say you want a function that returns the total cost of ingredients for a meal. Instead of writing it by hand, just type, 'generate a function that adds up the prices of ingredients.' Cursor will serve up this dish. Now, if you decide your recipe needs to be more specific—let’s say you only want to add prices under $20—you can refine the ingredients. Type in, 'make sure it only adds ingredients under $20,' and Cursor will adjust the recipe. It’s like adding spices; one prompt, and your recipe is perfectly customized. Now, let’s switch to editing an existing recipe in your code. Imagine you have a clunky function missing some flavor. Highlight the code, ask Cursor to 'optimize the function for better performance,' and Cursor will serve up a refined version, saving you time. Another fantastic feature is context awareness. Cursor knows which ingredients (files) you’ve been working with, so when it cooks your code, it considers everything it knows about your project. Now, let’s head over to the terminal and use the Prompt Bar there. In this case, it’s like asking Cursor to fetch the right cooking tools. For example, if you want to list all files in your directory but can’t remember the exact command, type, 'list all files in my project.' Here’s what Cursor brings to the table. Just like that, you have the command you need to get cooking. With CMD+Enter, you can run it immediately. Need a quick question answered about a command? Say you’re not sure what a certain flag does, like `-la`. Highlight the command, ask Cursor, and it will break down the ingredients (options) you’re using. So, whether you're cooking up code or grabbing the right tools in the terminal, the Prompt Bar in Cursor keeps your workflow simple and fun. Go ahead, give it a try, and stay tuned for more tips on making coding easier!