# Autocompletion & Suggestions in Editor

The **Autocompletion and Suggestions** feature in our Monaco Editor integration provides developers with intelligent, context-aware code completion for Solidity smart contracts. This feature leverages the Monaco Editor's capabilities, augmented by a custom backend API, to offer real-time suggestions, snippets, and ghost text, enhancing coding efficiency and reducing errors during smart contract development.

### Feature Overview

This feature is designed to assist developers by providing:

* **Context-Aware Autocompletion**: Suggestions are generated based on the current code context, such as keywords, function signatures, and Solidity-specific constructs (e.g., contract, function, event).
* **Code Snippets**: Predefined templates for common Solidity patterns like contracts, functions, events, and modifiers, which can be inserted with a single selection.
* **Ghost Text**: Inline preview of suggested code that can be accepted with a Tab key press, offering a seamless coding experience.
* **Custom Suggestion Box**: A UI component displaying detailed suggestions with documentation, types, and icons, triggered by specific keywords or key combinations (e.g., Ctrl+Shift+S).

#### Key Features in Detail

#### 1. Suggestion Box

* **Trigger**: Activated via Ctrl+Shift+S or automatically based on context.
* **Content**: Displays a list of suggestions with:
  * **Icons**: Visual indicators for types (e.g., ⚡ for functions, 📄 for contracts).
  * **Documentation**: Brief descriptions of each suggestion.
  * **Types**: Indicates whether the suggestion is a function, contract, event, etc.
* **Example**: Suggestions for contract include a full template with state variables, events, and functions.

<figure><img src="/files/wO6Puzt7jhKl5kD88GMa" alt=""><figcaption><p>Suggestion box</p></figcaption></figure>

#### 2. Autocompletion

* **Trigger Characters**: Suggestions are triggered by characters like ., (, {, =, and even a space, ensuring seamless integration into the coding workflow.
* **Solidity-Specific Suggestions**: Includes keywords (public, private), types (uint256, address), and snippets for common patterns.
* **Example**: Typing modifier suggests onlyOwner with a complete implementation, as shown in the screenshot.

#### 3. Ghost Text

* **Behavior**: Displays a preview of the suggested code inline, styled in italic with a dotted underline.
* **Interaction**: Press Tab to accept the suggestion, or continue typing to ignore it.
* **Performance**: Suggestions are fetched with a 300ms debounce to avoid overwhelming the backend.

<figure><img src="/files/0MI3gDjMRAkIzF1DiElC" alt=""><figcaption><p>Autocompletion-Ghost box</p></figcaption></figure>

### Benefits

* **Faster Development**: Focus more on logic, less on boilerplate.
* **Error Reduction**: Use verified and complete code patterns.
* **Learning Tool**: Great for beginners with inline docs and context.
* **Custom & AI Suggestions**: Supports both hardcoded templates and backend-powered, context-sensitive suggestions.

### Future Improvements

* Enhance AI suggestion accuracy by integrating a more powerful model.
* Add support for more languages beyond Solidity.
* Improve suggestion ranking based on user history and project context.
* Optimize backend performance for larger codebases.

This feature significantly enhances the developer experience by combining the power of Monaco Editor with intelligent, context-aware suggestions tailored for Solidity development.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.qremix.org/core-modules/autocompletion-and-suggestions-in-editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
