From 5c6f0e4d327fc8d36e26eab30ae4b27ad74208cd Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 4 Dec 2024 12:13:20 -0800 Subject: [PATCH] docs: add watch mode documentation --- aider/website/docs/usage/watch.md | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 aider/website/docs/usage/watch.md diff --git a/aider/website/docs/usage/watch.md b/aider/website/docs/usage/watch.md new file mode 100644 index 000000000..ebe831757 --- /dev/null +++ b/aider/website/docs/usage/watch.md @@ -0,0 +1,49 @@ +--- +title: Aider in your IDE +#highlight_image: /assets/browser.jpg +parent: Usage +nav_order: 750 +description: Aider can run in your browser, not just on the command line. +--- + +# Aider in your IDE + +If you run aider with `--watch-files`, +it will watch all files in your repo for edits. If you edit a file and add comments with "AI instructions", aider will follow them. So you can put aider messages right into your source files, nearby the code they refer to. + + +Specifically, aider will react to one-liner comments (# ... or // ...) that either start or end with `AI` or `AI!`. + +Comments that use `AI!` with an exclamation point are special. They trigger aider to take action to process all the AI comments and use them as instructions to make code changes. + +For example, if you included this AI comment in your code: + +```js +function factorial(n) +// Implement this. AI! +``` + +Then aider would update the file and implement the function: + +```js +function factorial(n) { + if (n === 0 || n === 1) { + return 1; + } else { + return n * factorial(n - 1); + } +} +``` + +This makes it easier to use aider from within your favorite editor or IDE. +See the demo video above of aider working with AI comments in VSCode. + +This capability is quite flexible and powerful once you get familiar with the various ways it can be used: + +- Just add #AI to a file to add it to the chat. +- Add an AI comment in the function you want changed, explaining the change request in-context. + - `# Add error handling... AI!` +- Drop multiple AI comments (in multiple files) before triggering aider with a final AI!: + - `# AI: Refactor this function...` + - `# ... into a method here in this class. AI!` +