Completions

Completions save keystrokes as you are typing code by providing a way to automatically complete partially-typed text. There are four types of completions in SlickEdit® Core:

Auto-Complete

Auto-Complete offers suggestions for how syntax, keywords, symbols, and lines of code may be completed by the editor. It works by looking at the word prefix under the cursor and using several different queries to find and suggest completion options. Each of these types of suggestions can be individually turned on or off, allowing you to customize auto-completion to your liking.

Using Auto-Complete

Auto-Complete is activated when the editor is idle for a short period of time and there is a partially-typed word under the cursor. When Auto-Complete is active, the available completions are indicated in several ways:

  • A light bulb appears on the left edge of the editor.

  • A list of completions appears under the word being typed.

  • The rest of the completed word or statement appears to the right of the cursor.

These visual hints can also be individually turned on or off through the Auto-Complete options. See Language-Specific Auto-Complete Options.

Tip

Auto-Complete can be activated manually by using the autocomplete command. Bind this command to a key sequence if you use it frequently. See Creating Bindings for more information.

To cancel out of Auto-Complete mode, use the Escape key.

To scroll through the items in the completion list, use the Up, Down, PgUp, and PgDn keys. Optionally, you can use Tab and Shift+Tab to cycle through the choices.

If a completion is selected, you can press Space, Enter, or any non-identifier key to cause the selected completion to be inserted along with the character typed (except for Enter).

Use Shift+Space to insert a real space rather than the completion. Use Ctrl+Shift+Space to insert the next character of the currently selected completion. This can be useful if you only want part of the word being completed and you do not want to type it yourself. Optionally, pressing Tab will cause auto-completion to attempt to insert the longest unique prefix match of all its completions.

If the completion has comments, you can use Shift+PageDown, Shift+PageUp, Shift+Home, or Shift+End to page through the comments. Use Ctrl+C to copy the comments for the current item to the clipboard.

Auto-Complete options can be configured on a language-specific basis. See Language-Specific Auto-Complete Options for information.

Auto-Close

Auto-Close will automatically insert closing characters for bracketed and quotation punctuation pairs. The following list shows the available pairings.

  • Parenthesis ( )

  • Bracket [ ]

  • Angle Bracket < >

  • Double Quote " "

  • Single Quote ' '

  • Braces { }

Note

SlickEdit Core automatically closes block comments. For example, in C++ when you type "/*" SlickEdit Core automatically inserts "*/". This is not part of the Auto-Close feature. To configure this, go to Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Comments and check or uncheck Automatically close block comments See Language-Specific Comment Options.

Auto-Close can be configured, as well as enabled/disabled, on a language specific basis. Specific pairs can also be enabled/disabled per language, as well as automatically inserting padding for Parenthesis, Brackets and Angle Brackets. To do this, select Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Auto-Close. For more information on Auto-Close options, see Language-Specific Auto-Close Options.

When an opening character in a pair is typed, the closing character will automatically be inserted. The closing character is automatically overtyped if you key in the matching close character as you are typing, helping to avoid any syntax errors. There are also navigation helpers when the close character is inserted. A hotspot marker is inserted on the right edge of the closing character. When this marker is visible, TAB or ENTER key will jump to the next column past the close bracket, and ESC will dismiss the marker as well as dismiss overtyping of the close character. Editing outside of the punctuation pair will also automatically dismiss the marker. You can disable the TAB or ENTER navigation key (or both) in Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Auto-Close. If both TAB and ENTER are both disabled, the hotspot marker is not inserted, though overtyping is still available.

When enabled, Auto-Close will only insert the matching closing character for the specific punctuation where appropriate for the current language. This is determined by scanning the current location and line. For example, it does not insert any closing characters in comments or strings. In the C++ language, the angle brackets are only auto-closed when following the template or cast keywords (ex: static_cast).

Word Completion

Word Completions search the current editor window for text matching the prefix at the current cursor position. Most completions are driven by Context Tagging®, matching symbols such as function names and variables. Word Completions can match any text in the current editor window, including comments.

Auto-Complete also lists word completions, but it is often faster to use key bindings to search for and insert Word Completions. The following is a list of commands for these operations and the key bindings in the CUA emulation. See Creating Bindings to change them.

  • complete_prev (Ctrl+Shift+Comma) ® Searches backwards through the current editor window to find a match.

  • complete_next (Ctrl+Shift+Dot) ® Searches forwards through the current editor window to find a match.

  • complete_more (Ctrl+Shift+Space) ® Adds subsequently more text from the matched line to the cursor position, allowing you to extend the amount of text inserted.

The following example of code shows how word completion is used:

if (pWindowView->pBuffer->LineNum>100) {
pW<Cursor is Here>
}

Press Ctrl+Shift+Comma,Ctrl+Shift+Space,Ctrl+Shift+Space to obtain the following result:

if (pWindowView->pBuffer->LineNum >100) {
pWindowView->pBuffer->LineNum <Cursor is Here>
}

Pressing Ctrl+Shift+Comma matched "pWindowView" in the previous line. If you wanted to match an earlier occurrence beginning with "pW", press Ctrl+Shift+Comma to find the next previous match. This also changed "pW" on the second line to the matching text, "pWindowView". Pressing Ctrl+Shift+Space extends that selection, matching "pWindow->pBuffer". Pressing Ctrl+Shift+Space, again, extends the selection to include "pWindow->pBuffer->LineNum".

You can easily see how this would save time typing in multiple lines that access structs, class members, arrays, etc.

Configuring Completion Settings

To configure Auto-Complete settings, from the main menu, click Window → SlickEdit Preferences → Languages, expand your language category and language, then select Auto-Complete. See Language-Specific Auto-Complete Options for more information.