CodeSense
CodeSense is Espresso's contextually-aware auto-completion:
"Contextually aware" means that CodeSense will suggest auto-completions based on where your cursor is located. So if your cursor is inside of an <a> tag, CodeSense will suggest attribute names. If you create a target attribute inside of that <a> tag, CodeSense will then suggest _blank, _top, and so forth to fill that attribute. If you are inside of a <p> tag, CodeSense will not even suggest the target attribute.
Using CodeSense
Typically CodeSense will open automatically when it detects that there are auto-completions that may be what you are looking for, but if you are wondering if there is any CodeSense available for your particular situation you can press escape to open it if there are completions for where your cursor is. Press escape again to close it.
If one of the entries within CodeSense is what you want to use, there are several ways to select it:
- Use the down and up arrow keys to select the item you want, then press tab or enter
- Continue typing to filter the list until what you want is the top item, then press tab or enter
- Click the item you want with the mouse
If the items in a CodeSense list share a common delimiter character, you can often quickly filter the list using that character. So, for instance, if you are coding CSS and you type "bo" CodeSense will suggest border, border-bottom, border-bottom-color, and more. If you then type "-", CodeSense will insert border- into your document and suggest border-bottom, border-bottom-color, and more. If you then type "t-", CodeSense will insert border-top- into your document and suggest border-top-color, border-top-style, and more.
For some languages, you can also accept a CodeSense completion by using the final shared delimiting character. For instance, typing "m:" in CSS will prompt CodeSense to insert margin: the same as if you typed "m tab" or "m enter" because all CSS properties have a trailing colon.
Many CodeSense insertions are actually snippets, particularly for function calls, HTML elements, and other complicated insertions. If you use CodeSense to insert something into your document and notice that the cursor either is not positioned at the end of the code that was inserted or else there is something selected, try pressing tab; odds are good that CodeSense has inserted a snippet with tab stops to make it easier for you to customize the auto-completion.
Every language that comes with Espresso has completions of its own.
Completions from your project
As well as what it knows about each language, CodeSense offers what is in your own files:
- Class names and ids. In a
classoridattribute, and after a.or a#in a selector, CodeSense offers the class names and ids found in your project's stylesheets and pages. - Paths to files. In
href,srcand similar attributes, insideurl( )and after@import, CodeSense offers the project's files, written as a path from the document you are in, with the nearest files first. - Words in the document. Once you have typed three letters of a word that is already somewhere in the document, CodeSense offers it. This is how the name of a function or variable you have written is completed. You can turn it off with Suggest words that are in the document in the Text Editing preferences; the words are still offered when you ask with escape.
Class names, ids and paths are offered for documents in a project.
CodeSense and LatteAI
CodeSense completes the name you are typing, from a list. LatteAI suggests whole lines, in grey after the cursor. The two work side by side: while the CodeSense list is showing, LatteAI holds its suggestion back.